Word macro to print the first page on letterhead (VBA code)
📅 ✍️ By Tim Kempster
Many law firms and offices print letters with a Word macro: page 1 from the letterhead tray, the rest from plain paper, sometimes a file copy too. Below is a macro that does exactly that, how to find the tray numbers for your printer, and the problems you will hit when you roll it out to more than one PC.
The macro: first page on letterhead, other pages on plain paper
Word stores the tray for the first page and for the other pages in the document's Page Setup. A macro sets those two values, chooses the printer, prints, and then puts everything back so the document is not saved with your tray settings:
Sub PrintOnLetterhead()
Dim oldPrinter As String
Dim oldFirst As Long, oldOther As Long
oldPrinter = Application.ActivePrinter
' Choose the printer without changing the Windows default printer.
' The name must match the printer name exactly as Windows shows it.
WordBasic.FilePrintSetup Printer:="Office HP LaserJet", _
DoNotSetAsSysDefault:=1
With ActiveDocument.PageSetup
oldFirst = .FirstPageTray
oldOther = .OtherPagesTray
.FirstPageTray = 260 ' letterhead tray (printer-specific)
.OtherPagesTray = 261 ' plain paper tray (printer-specific)
ActiveDocument.PrintOut Background:=False
' Put the document back the way it was
.FirstPageTray = oldFirst
.OtherPagesTray = oldOther
End With
WordBasic.FilePrintSetup Printer:=oldPrinter, _
DoNotSetAsSysDefault:=1
End Sub
To use it, press Alt+F11 in Word, open Normal > Modules (Insert > Module if there isn't one), paste the code, change the printer name and the two tray numbers, then add the macro to the Quick Access Toolbar or a ribbon button.
How to find the tray numbers for your printer
Word has named constants such as wdPrinterUpperBin and wdPrinterLowerBin, but most modern printer drivers ignore them and use their own numbers (often values like 257, 258, 260 or 261). The reliable way to find them:
- Select the printer in Word's print screen.
- Go to Layout > Page Setup > Paper and choose the tray you want for First page and Other pages. Click OK.
- Press Alt+F11, then Ctrl+G to open the Immediate window.
- Type
?ActiveDocument.PageSetup.FirstPageTrayand press Enter. Do the same forOtherPagesTray.
Those numbers are what the macro needs — for that printer model and that driver.
Where printing macros break
The macro above works well on one PC with one printer. The trouble starts when it has to work for a whole office:
- Tray numbers are different for every printer model and driver. Replace the printer, update the driver or switch from PCL to PostScript and the numbers can change, so the letterhead comes out of the wrong tray. Every printer needs its own version of the macro.
- Printer names differ between PCs. The same printer can have a different name, or a different port suffix such as
on Ne03:, on each PC and in each Remote Desktop or Citrix session. A hard-coded name fails on the next machine. - Getting the macro to everyone. Macros live in Normal.dotm or a template that has to be copied to every user and kept up to date. Macro security settings, the Trust Center and signed-macro policies can block them.
- Every extra need means more code. A file copy on plain paper, a matching envelope, duplex, a "COPY" watermark, a different number of copies, printing selected pages — each one is more VBA to write, test and maintain.
- When it goes wrong, someone has to debug it. Usually the person who wrote the macro has moved on, and nobody wants to touch it.
If Word seems to ignore the tray the macro sets, the printer driver is usually overriding it — see Word ignores printer tray settings.
The no-code alternative: Tray Selector
Tray Selector replaces printing macros with buttons on the Word ribbon. Each button remembers the printer, the tray for the first page and for the other pages, copies, duplex, extra copies to another tray, envelopes and watermarks. Instead of tray numbers, you pick trays by the names the printer driver reports, and you set it up through a settings screen rather than in VBA.
- Install Tray Selector
- Set up your buttons — e.g. "Letter", "Letter + file copy", "Envelope", "Draft"
- Click a button to print
Much more than a letterhead macro
A letterhead macro does one job. Tray Selector gives you all of this, set up once and then a single click every time — with macros, each item below would be another piece of VBA to write and maintain:
"Letter", "Letter + file copy", "Envelope", "Draft", "Duplex" — each with its own printer, trays and options.
No print dialog, no Printer Properties, no Page Setup. Click the button and it prints.
Print the letter on letterhead and a file copy on plain paper, or to a second printer, in the same click.
Print the matching envelope before or after the letter, from the envelope tray.
"COPY", "DRAFT" or "FILE COPY" added when you print — on every page or the first page only — without changing the document. More about watermarks.
Switch between single-sided and two-sided printing without opening printer settings. Duplex printing.
Set the number of copies per button or ask each time; print a page range or selected pages.
Hide headers and footers while printing so they don't print over the letterhead. How it works.
Print merged letters with the right trays, or split a document into sections that each print as a separate job.
Combine buttons for complex jobs, and copy button settings between users. Chaining buttons.
HP, Canon, Epson, Brother, Xerox, Lexmark and others, plus PDF printers and print management queues.
Word for Windows including Microsoft 365, 32- and 64-bit, Remote Desktop and Citrix.
For IT teams it removes the macro roll-out problem: Tray Selector installs silently by MSI, works in Remote Desktop and Citrix, can use the current default printer so the same button works on every PC, and settings can be deployed and locked centrally. See the IT deployment guide.
Already have macros that do other work? You don't have to throw them away: Tray Selector buttons can run a Word macro before or after printing, and your own VBA can click Tray Selector buttons. The help guide explains how.
Macro or Tray Selector?
- A macro is fine if you're one person, with one printer that won't change, and you're happy to edit VBA.
- Tray Selector is easier if several people print letters, you have more than one printer model, you use Remote Desktop or Citrix, or you need file copies, envelopes or duplex as well.
Tray Selector has a 7-day trial with every feature, so you can set up your letterhead button and compare it with your macro. Download Tray Selector.