MrExcel Publishing
Your One Stop for Excel Tips & Solutions

How to start and run an Excel macro from command line?

Posted by Piero on December 13, 2001 2:15 AM

I've a schedulation, and I need to put inside it a step that can call an excel file in order to start the macro contained in the file itself.
I've tried with :
"c:\path\excel.exe /m DoIt(4)".
but I think that I've applied it wrong, it doesnt work.
Or is that an incorrect syntax?
Are there any others solutions?

Posted by Rick E on December 13, 2001 7:33 AM

Put the macro in or call the macro from the Auto_Open sub of an Excel workbook, then open the workbook that has the macro.

So it would look like this:

Private Sub Auto_Open()
End Sub

Then enter on the command line:


This should open the Excel workbook (change the name of course to what the workbook is named)and run the macro DoIt.

Try that! Rick E.