-
I want to run microsoft word, open a document and run a macro from the command line. I can run word and open a document no trouble using the following in the run command from my stat menu.
"C:\Program Files\Microsoft Office\Office\WINWORD.EXE" c:\1.doc
but how do I attach a macro command on the end so it will run automatically when word opens. I ONLY want the macro to run when it is opened in this method not when the document is opened in the normal way for editing.
-
Hi davidrobin !!!
look at
http://support.microsoft.com/support...-US&SD=gn&FR=0
there you find the startup commands.
If the macro starts also if you open the word document
at you "normal way" then check out the events
DOCUMENT_OPEN or
AUTO_OPEN
in the vba Editor of this document.
-cu TheOnly
-
We use this all the time. We just take another aproach to this than the previous answer.
We make a template of the document. Then you can use the Document_New event. This will only execute when you open it like your demonstartion and tuns the macro.
When opening the document it looks for the Document_Open event wich is not here. The only problem is saving the file. It wants to make a Doc file of it and with another name then the original. Ofcourse it's possible to bypass this by using the document_close event. By setting making an automated saving routine, all you want is there.