How to -> Start Excel from command line and run a macro

  • Thread starter Thread starter Mickey A
  • Start date Start date
M

Mickey A

I have an Excel spreadsheet with a macro. What I want to do is to be able to
start this spreadsheet via a BAT file(mainly to schedule the running). But
the kicker is to run the Macro. I realize I may have to disable the security
to get passed the ENABLE/DISABLE prompt..or is there another way to handle
that too?

I have gotten close by getting EXCEL to load my spreadsheet but I am stuck
on the "right way" to handle the prompt and autostart the macro.

Any help will be appreciated.
 
Hi Mickey A,

You might try creating your own signature with SelfCert.exe; then you
can teach Excel to always recognize your own code and allow it to run
without disabling security for everyone else. Not sure if that will
help the macro run from the BAT file launch - but it might be handy for
a few other things - or at least save you a few minutes here and there.

Vincent
 
Mickey A,

Once you've followed Vincent's advice and disabled security prompt,
could you not do the following to run the macro?:

Private Sub Workbook_Open()

Application.Run "Book1!Macro1"

End Sub

Where Book1 is your workbook name and Macro1 is the name of the macro.


Cheers - David
 
Back
Top