Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I open Word and run a macro from DOS command line?

Status
Not open for further replies.

Apollo6

Technical User
Jan 27, 2000
418
US
I want to write a .bat file that opens Word and executes a macro in Word. I have done this before in Access but can't find anything about it in Word...

Thanks
 
Check out these articles on Microsoft.com - Q134742 and Q70014. They might help you out.
 
from the command line or in the bat file,
winword.exe /m(macro)

then immediately after the /m (NO space) put the macro name

example: winword.exe /mplt1

runs the plt1 macro in Word
 
Thanks for the suggestions...What I ended up doing was renaming the macro to &quot;AutoExec&quot;. In addition, to keep the macro from running whenever Word is openned from the desktop, you change the Target path on the shortcut by adding <space>/m to the end of the path. This prevents any macros from running when the app is ran from the shortcut. However, running the app from a batch file allows the AutoExec macro to execute because it is ran straight from the executable.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top