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: Controlling the Printer in a Macro.

Controlling the Printer in a Macro

Written by Allen Wyatt (last updated March 20, 2021)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


1

Many of the printers available on the market these days have some amazing capabilities. Most of these capabilities are accessible by displaying the Properties dialog box for the printer. 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"

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9178) 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: Controlling the Printer in a Macro.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Speeding Up Document Display

Are your documents displaying too slowly? You can configure Word so that it is as quick as possible on displaying by ...

Discover More

Calculating Fractions of Years

When working with dates and the relationship between dates, Excel provides a variety of worksheet functions that may ...

Discover More

Forcing Word to Display Spelling and Grammar Errors

If your document has enough spelling errors in it, Word informs you that you have too many and then refuses to display ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Scaling Your Printing

If you want to cram more of your worksheet onto each page of a printout, one way to do it is by using scaling. Here's how ...

Discover More

Printing Odd or Even Pages

When you print a worksheet, Excel normally prints all the pages or a consecutive series of pages that you specify. If you ...

Discover More

Printing a Range of Pages

If your worksheet, when printed, requires more than a single page to print, you may want to only print a range of the ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is nine minus 5?

2022-01-20 18:20:16

Sarah V

How does one go about creating a printer definition for a specific set of presets, as noted above (the HP Regular Paper and HP Glossy)?

Is it something that one does through printer properties, or are you basically adding the same physical printer multiple times, each time setting the preferences to what you want?

Thanks


This Site

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.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.