Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Controlling the Printer in a Macro.
by Allen Wyatt
(last updated June 6, 2019)
Many of the printers available on the market these days have some amazing capabilities. Most of these capabilities are accessible by using the Print dialog box and clicking on the Properties button next to the printer name. As you are developing your own macros, you may wonder if it is possible to access these capabilities from within the macro.
Unfortunately, it doesn't appear that this can be done because the printer drivers don't typically make the features of printers available in a way that can be understood and accessed from the object model used by VBA. (Boy, was that a mouthful!) Instead, you would have to use the actual Windows API, and even then not all features may be accessible.
There are some workarounds that can be used, however. You can use VBA to select different printers to which you can direct your output. This means that you can create different printer definitions—in Windows—and then use those definitions as the target for your output.
For example, you could use the Printers folder in Windows to set up a printer named HP Regular Paper. That printer definition can be set to print on regular paper, by default. You can then set up another printer definition named HP Glossy Paper and set it to print, by default, to a tray that may contain glossy paper. With the two printers defined, you can then use VBA to switch between the two. For instance, if you wanted to print to the printer definition for the glossy paper, you could use the following in your macro:
Application.ActivePrinter = "HP Glossy Paper"
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2530) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Controlling the Printer 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!
The security features built into Excel 2002 and 2003 allow you to digitally sign your macros so that users can rest ...Discover More
Excel doesn't provide an easy way to grab the worksheet name for use within a worksheet. Here are some ideas on ways you ...Discover More
Excel allows you to add pictures to your worksheet, even within a macro. However, you might have a bit harder time ...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 menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.