I have a batch file that does several things and the last step is to open an excel document and run the macro contained in it which updates the contents of the file. The macro runs perfectly with the click of a button but I want it all to be done when you run the .bat file.
I know I could attach the macro to the open event so it runs when you open the macro but I only want it to update automatically when you run the bat file, not every time you open the thing.
Maybe I could pass a parameter to let it know that it’s been run from a .bat? or run it directly with an excel command?
like this?
run excel.exe /runMacro "mymacro"
I can’t find what I need anywhere, thanks.
Yes, basically the easy way is to move the contents of your “mymacro” into your ThisWorkBook
With security, the user may still have to click the enable macros button unless you want this to be unattended. If you want to pass arguments into the workbook open, then you can do this by parsing the command line. You can search code examples on Google for “excel GetCommandLineW”