How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site. Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask Network Engineer Your Own Question
Network Engineer
Network Engineer, Computer Hardware Engineer
Category: Computer
Satisfied Customers: 197
Experience:  30 Years Experience Hardware and Software Support,Mac OS X, Expert.
Type Your Computer Question Here...
Network Engineer is online now
A new question is answered every 9 seconds

How do I start MS Word from the command line using the /m ...

Customer Question

How do I start MS Word from the command line using the /m command line switch to run a mcro that is not in the template?
Submitted: 10 years ago.
Category: Computer
Expert:  Network Engineer replied 10 years ago.
/m Starts a new instance of Word without running any AutoExec macros.
what you want is

/mmacroname Starts Word and then runs a specific macro. The /m switch also prevents Word from running any AutoExec macros.
so it would be

C:\Program Files\Microsoft Office\Office\Winword.exe /mmacroname
Network Engineer and 9 other Computer Specialists are ready to help you
Customer: replied 10 years ago.
This works fine for macros that are in the global template; however, I am trying to reference a macro in another template that I have placed in the startup directory for Word and it still refuses to work. I had thought there was some way to specify the actual location of the macro such as template.module.macro but that failed too.
Expert:  Network Engineer replied 10 years ago.
/ttemplatename Starts Word with a new document based on a template other than the Normal template.

thats about it accourding to there support site.
You used to be able to do that in the older versions,Word.Template.x, where x represents MS-Word version .... Macro.1, Microsoft Access module macro, Can contain malicious behavior so they stopped people from doing it.
Customer: replied 10 years ago.
The /t and /m switches cannot be used together and there are numerous macros within the template rather than any autoexec macro.
Expert:  Network Engineer replied 10 years ago.
The DOT template is the first document opened when you launch MS Word.

If a macro named AutoExec is in the "" template or in a global template stored in Word's startup directory, it is executed
Customer: replied 10 years ago.
Would I then somehow use the autoexec macro to launch the desired macro within the other module based on the document name or do I need to create numerous global templates each with an autoexec macro and specify them on the startup line acordingly depending on the document I am loading? I got an autoexec macro to work in the global template I had created (not but it doesn't want to launch the macro I really want to run; perhaps I am referencing it incorrectly on the command or should be trying another command.

Thanks for all your help.
Expert:  Network Engineer replied 10 years ago.
rename to and name yours and see if that works.

I did see this tho om the support site.
When you run a Visual Basic For Applications macro containing the "Application.Run Macroname:=" command in Microsoft Word or in another Office program to automate Word, you may receive the following error message:
Run Time error '4366' : Unable to run the specified macro.

You have included a template name as part of the Macroname argument string.
Back to the top

Remove the template name from the Macroname argument.
Customer: replied 10 years ago.
I have been able to create an autoexec macro in the global template and it works fine when I specify that template name using the /t switch on the command line as long as it is located in my startup directory. Unfortunately, it does not work if I open any other document by double clicking on it or simply try opening Word. The macro assigns the value to a variable which is then used to determine which other macro to run. This now creates a run-time error 4248 (command is unavailable because there is no document open). If I move the template from the startup directory to another location, the problem goes away but the autoexec macro will not run even with the /t switch (even if it is my templates directory). Now I need a awy around this run-time 4248 error and am not having any luck finding it on any microsoft support sites including MSDN.

I've tried the workarounds that are suggested on the Microsoft site using the error handler to trap the error and exit the macro; however, this completely defeats the purpose of having an autoexec macro. I will now see what happens if I comment out the entire autoexec macro and call the individual macros by name with the template still in the startup directory but have my doubts.

Any ideas?

I'm paying now as my initial question has been answered.

Thank you.
Expert:  Network Engineer replied 10 years ago.
Found it here for you..
as how to fix it is beyond me .

Run-time error '4248':
This command is not available because no document is open.
Back to the top

This problem may occur if you do not have a document open, or if the document that you are referencing is not open. Word can only change the properties of an open (or visible) document.

Note These error messages may also appear if you open the document with the Visible property set to False.