I'm writing a command-line program that has a step in which I need to replace text in a Word file. The replacing task is accomplished using Word macro.
What I need to do now i开发者_如何学编程s to call this macro from command-line. At the moment we can do this by using the /mMacroName
parameter of 'winword.exe', i.e. <path-to-msoffice>\winword.exe /mMacroName
. But this needs the macro to be already available as a global macro.
Since I need to run the program on another computer, I need to import the above replacing macro programmatically... and I don't know how to do this.
Adding the macro using VBScript would be an option. You can find a sample to get started in the following related question:
Remove MS Word macro using VBScript
精彩评论