Thursday, February 23, 2012

Run VBA Macro from another file via Command Line.

Microsoft Office Macro in a file other than the "Normal" template.

VBA Macro can be run from Command line using the following syntax:
WinWord {Path\to\Macro\File} /mMacroName

This will not work if you have set your Macro Security to any thing other than "Allow all macros"

To fix this:
I suggest you select: "Allow only signed Macros"
Now Sign your Macro Project using a Self Certificate from "Office Tools" > "Digital Signatures"
You will have to Place a copy of the Certificate in "Root Authority"

Still - No effect on calling from the command line. This is because even though the Macro Project is Digitally Signed - it is only self-signed; thus you will have to explicitly authorize this macro project's publisher - which is: you.
For that open the macro project document/Template - and you will be prompted to allow the "Self Publisher".

Once this is done - the macro can be run directly from the command line.

No comments: