Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021. 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: Specifying a Paper Tray in a Macro.

Specifying a Paper Tray in a Macro

Written by Allen Wyatt (last updated August 26, 2023)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021


If you use macros to print documents, you already know that the macro can specify the actual printer to which output should be sent. What if you want to also specify a specific paper tray to be used on that printer? Unfortunately, this gets to be a bit of a sticky wicket in Word. A brief tour and explanation will help to clarify why this is the case.

Which paper tray is used by Word depends on a number of factors, some of them not under the control of Word itself. For instance, consider the following, some of which are dependent on the version of Word you are using.

  • If you display the Word Options dialog box and click on Advanced, in the Print group you can specify a Default Tray.
  • If you display the Page Layout tab of the ribbon and then click the icon at the bottom-right of the Page Setup group you'll see the Page Setup dialog box. On the Paper Source tab you can specify which paper tray to use for the first page and which to use for subsequent pages.
  • If you press Ctrl+P to print and then click Properties, you can often (depending on your printer) rummage around and select a paper tray.

Thus, Word has two places where you can specify paper trays, and your printer may have its own place to set a paper tray to use. This final setting area (through the Properties button) is beyond the "reach" of VBA—the dialog box displays settings in the printer driver, not in Word itself.

To make matters worse, there is no clear-cut explanation available concerning which settings have precedence in any given print job. Do the settings in the Page Setup dialog box override the printer driver setting? Does the printer driver setting override the Word Options dialog box setting? How does the Word Options dialog box setting relate to the Page Setup settings? You get the idea; a multitude of settings, combined with the vagaries of different printer driver settings and printer capabilities can lead to confusion; what may work in one mix of conditions might not work in another.

That being said, there are several approaches you can try in order to control the paper tray selection via a macro. It is important to keep in mind that your macro can specify settings in the Word Options dialog box, as well as in the Page Setup dialog box. Your macro cannot, however, specify settings accessible through the Properties button of the Print dialog box. (More on this in a moment.)

If you want to set the Page Setup tray settings, you can do so using a macro similar to the following:

Sub CustomPageSetup()
    Dim strTrayFirst As String
    Dim strTrayOther As String
    Dim lngTrayFirst As Long
    Dim lngTrayOther As Long

    'Other setup code goes here

    strTrayFirst = System.PrivateProfileString(strIniFile, _
      "Printer Trays", "Letter First")
    If strTrayFirst <> "" Then
        Select Case strTrayFirst
            Case "Automatic Sheet Feed"
                lngTrayFirst = wdPrinterAutomaticSheetFeed
            Case "Default Bin"
                lngTrayFirst = wdPrinterDefaultBin
            Case "Large Capacity Bin"
                lngTrayFirst = wdPrinterLargeCapacityBin
            Case "Large Format Bin"
                lngTrayFirst = wdPrinterLargeFormatBin
            Case "Lower Bin"
                lngTrayFirst = wdPrinterLowerBin
            Case "Manual Feed"
                lngTrayFirst = wdPrinterManualFeed
            Case "Middle Bin"
                lngTrayFirst = wdPrinterMiddleBin
            Case "Upper Bin"
                lngTrayFirst = wdPrinterUpperBin
            Case Else
                lngTrayFirst = wdPrinterLowerBin
        End Select
    End If

    strTrayOther = System.PrivateProfileString(strIniFile, _
      "Printer Trays", "Letter Other")
    If strTrayOther <> "" Then
        Select Case strTrayOther
            Case "Automatic Sheet Feed"
                lngTrayOther = wdPrinterAutomaticSheetFeed
            Case "Default Bin"
                lngTrayFirst = wdPrinterDefaultBin
            Case "Large Capacity Bin"
                lngTrayOther = wdPrinterLargeCapacityBin
            Case "Large Format Bin"
                lngTrayOther = wdPrinterLargeFormatBin
            Case "Lower Bin"
                lngTrayOther = wdPrinterLowerBin
            Case "Manual Feed"
                lngTrayOther = wdPrinterManualFeed
            Case "Middle Bin"
                lngTrayOther = wdPrinterMiddleBin
            Case "Upper Bin"
                lngTrayOther = wdPrinterUpperBin
            Case Else
                lngTrayOther = wdPrinterUpperBin
        End Select
    End If
    With ActiveDocument.PageSetup
        .FirstPageTray = lngTrayFirst
        .OtherPagesTray = lngTrayOther
    End With
End Sub

This macro, despite its length, only sets two settings: the First Page setting and the Other Pages setting on the Paper Source tab of the Page Setup dialog box. The macro is also not complete, but only an example of how the actual "setting" could be done in your own macro. This particular code reads two settings from an INI file (the file name is specified in the strIniFile string), and then makes the settings based on the retrieved values. You would, obviously, need to supply the name of the INI file you wanted to use, as well as make sure that it was set up to contain the proper information in the proper format. (Setting up INI files is beyond the scope of this tip, but much information is available on the topic elsewhere.) Once the settings are read from the INI file, they are translated to settings that Word can understand, and then in the final With ... End With structure the dialog box changes are made.

For the reasons mentioned earlier, the approach exemplified in this macro might not work in all situations. If it doesn't, you may not be able to control the paper trays used by your printer, at least from a macro. Remember that the paper trays set through the Properties button are actually under the control of your printer driver, and the printer driver settings are not "visible" to VBA. A potential solution in this situation is to simply set up different printer drivers. Follow these general steps:

  1. Determine how many paper trays you want to use on the printer.
  2. Define a new printer in Windows for each paper tray you want to use. For instance, if you want to use three different paper trays, you would define three printers, each with a name representative of a paper tray.
  3. Right-click on a printer definition and change the properties of the printer so it prints to the desired paper tray.
  4. Repeat step 3 for each of the other printer definitions, making sure you specify different paper trays for each one.

At this point you have multiple printer definitions set up and each will print to a different paper tray on the same printer. You can now specify the desired printer, in a macro, so that the printout goes to the desired paper tray. The only drawback to this solution, of course, is that it takes quite a bit of setup work. If you work in an office with 50 users, this means you will need to make sure all 50 have each printer defined as described above.

Remember that the paper tray to be used by Word can be specified by the user through the selection of one or more settings in various dialog boxes, as detailed at the first of this tip. Because of this, some people have had success using the SendKeys statement to emulate the keypresses a user would use to specify a paper tray. (You can find information on SendKeys in the VBA online help available with Word.)

What SendKeys actually does is to stuff the keyboard buffer with a series of keypresses, just as they would be typed by the user. There is a potential problem with SendKeys, however. It can be unreliable because there is no way to insure that the keystrokes are actually going where you want. On a multi-threaded operating system (like Windows), some other process could intervene and derail the commands.

The bottom line is that, unfortunately, there is no "one size fits all" solution to selecting a paper tray using a macro. A solution that works for one person may not work for another. For this reason, you will need to experiment to see what solution will work best for you—but don't expect it to work for everyone else.

Note:

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

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (9320) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Word here: Specifying a Paper Tray 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

Special Characters in Pattern Matching

The most powerful search engine in Word uses pattern matching, but the way you specify special characters in a ...

Discover More

How to Stop a Table Row from Splitting Over Two Pages

Do you want your table rows to be split between pages? Word allows you to format the table so that rows stay together and ...

Discover More

Measuring Efficiency of Formulas and Macros

As the limits on what you can store in Excel have increased, so has the need to consider how to make your workbooks and ...

Discover More

The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2013. Spend more time working and less time trying to figure it all out! Check out Word 2013 For Dummies today!

More WordTips (ribbon)

Printing a Document's Mirror Image

If you need to print the mirror image (backwards) of a document, you may think you are out of luck in Word. There are ...

Discover More

Printing Outside the Boundaries All the Time

If Word thinks you are going to print in an area of the page that isn't printable, it will let you know. If you don't ...

Discover More

Two Page Numbers per Physical Page

Want to save paper when printing your document? Just print two pages per sheet of paper and you'll get rid of only half ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, 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 7 - 6?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

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.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, 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.