Make Sure background printing is enabled in word. On the Tools menu, click Options, and then click the Print tab. Under Printing options, ensure that Background printing check box is checked.
cd C:\Program Files\Microsoft Office\Office14 winword "c:\file.BAT" /q /n /mFilePrintDefault /mFileExit
Change to the folder of your office installation.
Command Line parameters to pass to Word.
/q - Start Word without splash screen.
/n - Start Word without a document being open.
/m(MacroName) - Start Word and run the named macro. The windows macro commands FilePrintDefault and FileExit do exactly what they say. Also there is no space between the /m and the macro name.
To get a list of macros open word, on the right hand side of the View tab of the ribbon bar there s a Macros button. Click it and change the "Macros In" dropdown box to Word Commands.
Word 2010 Macros |
Create macro for the globe settings.
Sub FilePrintToPrinter1() ActivePrinter = "Pritner1" Application.PrintOut _ FileName:="", _ Range:=wdPrintAllDocument, _ Item:=wdPrintDocumentWithMarkup, _ Copies:=1, _ Pages:="", _ PageType:=wdPrintAllPages, _ Collate:=True, _ Background:=True, _ PrintToFile:=False, _ PrintZoomColumn:=0, _ PrintZoomRow:=0, _ PrintZoomPaperWidth:=0, _ PrintZoomPaperHeight:=0 Application.WindowState = wdWindowStateMaximize End Sub
Now calling the this macro would be.
winword "c:\file.BAT" /q /n /mFilePrintToPrinter1 /mFileExit
Links
http://www.robvanderwoude.com/printfiles.phphttp://www.autohotkey.com/forum/topic10600.html
Very nice sharing do more like that
ReplyDeleteFYI, we were using this command for a long time, and with office 14, Word stopped quitting at the end.
ReplyDeleteChanging it to :
mFileCloseOrExit
fixed the problem here ...
Thank you yfital! Couldn't figure out why Word 2010 would no longer quit after printing.
ReplyDeleteThanks for sharing these useful tips. I've encountered several problems in printing word docs using office 2010 but, you helped me resolve those problems. I look forward to learning more about printing.
ReplyDeleteThat was a nice tip about eliminating the splash screen. My next line of investigation is to completely remove any screen interaction (so this runs in an offline environment) and to have my script wait until word has finished and exited. Any ideas?
ReplyDeleteMurray