2

I'm trying to execute a Word macro from a batch file. The documentation here indicates that this is accomplished using the /mMacroname switch.

However, when I do this, I receive an "Invalid switch - /mMacroname" error. It seems I'm doing something wrong, but I can't for the life of me figure out what it is.

The name of the macro is FormatStrikethrough. It opens/closes/etc. the file on its own. I am invoking it like so:

start "C:\Program Files (x86)\Microsoft Office\Office14\winword.exe" /mFormatStrikethrough
Travis
  • 1,044
  • 1
  • 17
  • 36
  • It tells me that /m is invalid, rather than /mFormatStrikethrough – Travis Mar 14 '13 at 17:54
  • Does it do what you want if you drop the start command? – Gray Mar 14 '13 at 19:18
  • 1
    Thank you, sir. Switching to a "cd " syntax then executing winword.exe directly fixed it for me. If you submit it as an answer, I'll mark it correct. – Travis Mar 14 '13 at 19:24
  • You don't need to switch to the directory first, you can just run `"C:\Program Files (x86)\Microsoft Office\Office14\winword.exe"` directly. Sorry that I overlooked the `start`. – Joey Mar 14 '13 at 19:31
  • I haven't tried it - will the quotes not throw it off? – Travis Mar 14 '13 at 19:42
  • Answered my own question - no the quotes will not throw it off. Thanks to both of you! – Travis Mar 14 '13 at 19:48

1 Answers1

2

Dropping the start from the command will make it work.

I believe this is because your parameters were being passed to start rather than the winword executable. As for how to use start to launch a program with switches,

This answer seems to tell you how to do that.

Community
  • 1
  • 1
Gray
  • 7,050
  • 2
  • 29
  • 52