Trigger VBA-Macros Application in Laravel

跟風遠走 提交于 2019-12-02 10:02:34

Well as long as using Internet Explorer you can use JavaScript on your button to call a macro:

<input type="button" value="Run My Macro" onclick="RunMacro("C:\MyFile.xlsm", "ThisIsMyMacro");">

And using this function:

<script type="text/javascript" language="javascript">
    function RunMacro(FileName, MacroName)
    {
    var ExApp;

    ExApp = new ActiveXObject("Excel.Application");
    ExApp.Workbooks.Open(FileName);
    ExApp.Run(MacroName);
    }
</script>

Then you need to wait until the macro is finished and trigger the upload event with JavaScript. Not sure about how we can detect that the macro has finished. Probably the easiest way would be to have one button to trigger the macro and then let the user click another button for uploading when the macro finished.


Another solution could be having a link that opens the file and it runs a macro on the Workbook_Open() event: Open excel file through normal html link. So the user needs to click that link before he can use the upload button.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!