Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Displaying the Print Dialog Box in a Macro.
by Allen Wyatt
(last updated June 5, 2021)
Before printing anything in Excel, it is not unusual to display the Print dialog box. This allows you to make changes to how the print job will be handled by the printer driver.
If you are creating a macro that is used to print information from your worksheets, you may want to display the Print dialog box programmatically. The user can then choose to print, directly from within your macro.
To add this capability, simply include the following macro line:
bTemp = Application.Dialogs(xlDialogPrint).Show
The Show method results in the Print dialog box being displayed. When this code line is finished, bTemp will be either True or False. If True, it means that the user clicked on OK in the dialog box, thereby printing something. If False, then the user either clicked on Cancel or the Close button to close the dialog box without printing.
You might wonder if this approach will work in Excel 2013 and later versions seeing as the program now uses what Redmond refers to as "Backstage view" to initiate printing. (Just press Ctrl+P and you can see the printing options in Backstage view.) Fortunately, it does. Later versions of Excel dutifully display the Print dialog box as it appeared in earlier versions of the program, bypassing completely the need for what you see in Backstage view.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10321) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Displaying the Print Dialog Box in a Macro.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
Do you get tired of the dialog box that says "do you want to enable macros" that is displayed when you open a workbook. ...Discover More
How Excel uses templates is different than how Word uses templates. This tip looks at those differences and discusses ...Discover More
The data stored in a worksheet can often correspond to information external to that worksheet. For instance, you might ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.