How to Print in Microsoft Word from the Command Prompt

I recently wanted to automate a task.  Part of that task was required printing a large file.  Here is the command for printing a file in Word from the command prompt:

"C:\Program Files\Microsoft Office\Office11\WINWORD.EXE" C:\path\file.txt /q /n /mFilePrintDefault /mFileExit

Let's break this down:
  • "C:\Program Files\Microsoft Office\Office11\WINWORD.EXE" - path to the Word executable with quotes around the entire path since it contains spaces.
  • C:\path\file.txt - Example path and file name to show placement within command.
  • /q - Start Word without splash screen.
  • /n - Start Word without a document being open.
  • /mFilePrintDefault - Start Word and run the named macro.  Here is the key to this problem -- FilePrintDefault is the command for printing.  And yes, there is no space between the "/m" and "FilePrintDefault" -- they must run together.
  • /mFileExit -  Exits Word once entire document has printed.
For more about Microsoft Word startup command prompt switches, see the Microsoft Support article How to use startup command line switches to start Word 2007, Word 2003, Word 2002, and Word 2000.

    No comments:

    Post a Comment

    Note: Only a member of this blog may post a comment.