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 normal.dot template?
Optional Information: OS: Windows XP; Browser: IEAlready Tried: Microsoft and MSDN support plus a google search.
/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
30 Years Experience Hardware and Software Support,Mac OS X, Expert.
This works fine for macros that are in the normal.dot 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.
/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.
The /t and /m switches cannot be used together and there are numerous macros within the template rather than any autoexec macro.
The DOT template is the first document opened when you launch MS Word.
If a macro named AutoExec is in the "normal.dot" template or in a global template stored in Word's startup directory, it is executed
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 normal.dot) but it doesn't want to launch the macro I really want to run; perhaps I am referencing it incorrectly on the application.run command or should be trying another command.
Thanks for all your help.
rename normal.dot to backup.dot and name yours normal.dot 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.
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 activedocument.name 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.
I'm paying now as my initial question has been answered.
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.