Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, and 2016. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Printing and Exiting Word in a Macro.
by Allen Wyatt
(last updated August 27, 2016)
Robert needs a macro that will load a document, print it out, and then exit Word. He's figured out how to load the document and start to print it, but when he tells the macro to exit Word, he sees a message saying that if he quits, any printing will be deleted.
This message is displayed because the default method for printing in Word is to print in the background, which means that the command to shut down Word is executed while the printing is still going on in the background. The solution is to make sure that background printing is turned off in the print command:
Since printing will be done in the "foreground," the next macro command will not be executed until the printout is complete. In this way, the printing is very much like printing from within Windows itself: right-click a document and choose Print from the Context menu, and Word is loaded, the document printed, and Word then shuts down.
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (10778) applies to Microsoft Word 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Word here: Printing and Exiting Word in a Macro.
Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!
When you are printing a document, it is not unusual to see messages (dialog boxes) periodically. When you want the ...Discover More
Do you use custom document properties? They can be very helpful, but sometimes hard to get at. This tip shows a way you ...Discover More
I often need to print only select pages of a document, rather than the whole thing. Word makes it easy to be judicious in ...Discover More
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.