Between May 2003 to April 2004 I subcontracted to Thames Valley Police on a Windows 2000 rollout where I came across a curious problem. A lot of the offices had multi-tray laser printers with headed paper in one tray and plain in another. On their old Windows 95 system they had a macro in Word which was accessed by a button on the toolbar. When executed, the macro sent the first page of an open document to the paper tray with headed paper and subsequent pages to the tray with plain paper.

Ideal for producing letters, but it just didn't work under Windows 2000. It took a lot of digging and experimenting but eventually I came up with a new default Word template which gave the users back this functionality and I document it here for anyone who may be in a similar position.

Although I would like to blow my own trumpet, I can't take credit for the Visual Basic code that makes up this macro. For the most part the code and further information can be found at: ...or... under knowledge base article 194789 (previously Q194789)

Quick Links for those who don't want to scroll through my waffle:

Maintenance and additions


Macro code

Mailmerge to printer

Download Normal.DOT containing the macro code

Waffle commences......

Under Windows 95 most printer drivers adhered to Word default constants for the numbering and selection of paper trays as below:

Value: Name:
0 wdPrinterDefaultBin
1 wdPrinterOnlyBin
1 wdPrinterUpperBin
2 wdPrinterLowerBin
3 wdPrinterMiddleBin
4 wdPrinterManualFeed
5 wdPrinterEnvelopeFeed
6 wdPrinterManualEnvelopeFeed
7 wdPrinterAutomaticSheetFeed
8 wdPrinterTractorFeed
9 wdPrinterSmallFormatBin
10 wdPrinterLargeFormatBin
11 wdPrinterLargeCapacityBin
14 wdPrinterPaperCassette
15 wdPrinterFormSource

Thus, telling Word that page one should go to tray 2 and subsequent pages should go to tray 1 resulted in a simple TVP Print macro that would split letter headed paper from plain. In fact, for the most part, the macro consisted of little more than this:

With ActiveDocument.PageSetup
.FirstPageTray = 2
.OtherPagesTray = 1
End With

Sadly, under Windows 2000, printer manufacturers have moved away from this list of constants to form their own proprietary lists which not only vary between manufacturers but also between models. This means if you have different printer models, there is no easy way of setting a document to print to selected trays without manually configuring the page setup before printing. This becomes a big problem for legacy applications which automatically mailmerge documents to the printer or for users who were used to running the old TVP Print macro which simply and easily split a document across two paper trays regardless of what printer was installed.

If users want to keep their automatic printing functionality, a new macro is required which can sort out available paper trays for itself.

Printers under Windows 2000

The list below shows the output values and names specified by a HP4100tn printer (left) and a HP4200tn printer (right) under Windows 2000. As you can see, both the names and numbers vary just between these similar models from the same manufacturer.

Value Name:   Value: Name:
7 Auto Select   15 Automatically Select
4 Manual Feed   265 Printer auto select
1 Tray 1   264 Tray 1
2 Tray 2   263 Tray 2
11 Tray 3   262 Tray 3 (500-Sheet)
16640 Plain   258 Manual Feed (Tray 1)
16641 Preprinted   1268 Unspecified
16642 Letterhead   1267 Plain
16643 Transparency   1266 Preprinted
16644 Prepunched   1265 Letterhead
16645 Labels   1002 Transparency
16646 Bond   1264 Prepunched
16647 Recycled   1263 Labels
16648 Color   1262 Bond
16649 Cardstock   1261 Recycled
16650 Rough   1260 Color
      1259 Cardstock >164 g/m2
      1258 Rough
      1257 Envelope

This is where we have a problem. The traditional macro under Windows 95 simply splits the printout between tray values 2 and 1 which are irrelevant numbers for these printers under Windows 2000. There are other discrepancies too. A print job could be split on the 4100tn by sending it to tray values 11 and 2 (Tray 3 and Tray 2), however using equivalent values on the 4200tn (262 and 263) does not work with all 4200tn printers! The only way to correctly split the print job on the 4200tn is by sending it to tray values 1265 and 1267 (Letterhead and Plain).

So, of all the multiple-tray printers Thames Valley Police have, each has its own naming/numbering convention. Under Word, each document's page setup can be manually configured to send the correct page to the correct tray as below:

But of course, manually configuring each document is time consuming and is not something the users want after having it so easy under Windows 95. What the users want is their old TVP Print functionality back where they just click a single button and it sorts out the page setup for them.

This is achievable thanks to the new TVP Print macro which does the following:

It interrogates the default printer driver to find the tray names and numbers;
The numbers it finds tell it what make/model of printer it's talking to;
It configures Page Setup in Word to split the print job between the headed and plain trays;
It sends the job to print.

TVP Print can also:

Create multiple copies of the printout if requested to by the user;
Create a headed copy and then a plain copy for TVP records (known as one plus one printing);
Insert the current date into the document (included for legacy reasons);
Run from keyboard shortcuts to minimise user intervention;
Display printer tray names/numbers for faultfinding purposes.

All application servers have the TVP Print macros installed in their default Word template. Someone using this Word template will have toolbar buttons similar to those shown below:

The yellow smiley face button and the TVP Print button are both parts of the TVP Print function. Pressing Smiley will cause a version window to pop up similar to the one below:

The version window will tell you when the template was last updated. Pressing the TVP Print button or the CTRL-SHIFT-L keyboard shortcut will bring up the following dialogue box:

Again, the version number is shown in the lower left corner. The user can make the appropriate selection from the two printing choices, enter the number of copies required and click OK to confirm. The macro will then assign the correct pages to the correct printer trays.

Adding new printers.

TVP Print currently works with the following printers:

Oki 24 (using DX driver)
Oki 20+
Tally T9116D (using HP LaserJet IIIP driver)

If a new multi-tray printer is purchased then install and configure it, run TVP Print and click the About button. TVP Print will report back the printer's available tray names/numbers similar to the example below taken from a HP 4200tn:

The numbers representing the trays you want to send the document to then need to be added into the TVP Print macro in the same way that existing numbers have been entered. For more on adding new printers, see maintenance and additions at the end of this page.

The Macros in Normal.DOT

Entering the macro menu will show up the following macros with a description of their function below:

Macro Name: Function:
chqprta.MAIN Printing macro for the Aptos accounting system used by Thames Valley - unmodified from original Normal template
CTRLALTP CTRL-ALT-P keyboard shortcut points to this macro (bypasses GUI)
CTRLSHIFTP CTRL-SHIFT-P keyboard shortcut points to this macro (bypasses GUI)


Inserts the current date into the document - as in original Thames Valley W95 macro
OnePlusOne Prints headed copy then plain copy of current document
SingleHeaded Prints only the headed copy of the current document
Test Shows Word File Locations - unmodified from original Thames Valley Normal template
TVPPrint Brings up GUI interface for TVP Print
Version Shows version of TVP Print (Smiley button points to this)

How TVP Print Works - a technical explanation.

The Smiley and TVP Print buttons that have been added to the toolbar in Word point to the Version and TVPPrint macros respectively. When TVP Print is selected by either the CTRL-SHIFT-L keyboard sequence or by the user clicking on the button, the TVPPrint macro is executed. This macro calls two functions, GetBinNumbers and GetBinNames. Both macros interrogate the default printer driver to find the available tray numbers and names which are then inserted into an array. As different printers have varying amounts of available trays, the size of the array is set dynamically to match the amount of trays it sees. The array is then searched by an integer variable which runs through the retrieved tray numbers comparing them to known values. If a match is found then the macro knows the printer model it is talking to.

An example of this working is with the 4100tn shown earlier. When interrogated by the GetBinNumbers function, the array will contain the numbers 7,4,1,2,11 and the numbers 16640-16650. Tray 3 has a value of 11 which is not used on any of the other multi-tray printers in Thames Valley Police, therefore when the array is searched, if the value 11 is found the macro assumes it is talking to a HP4100TN.

Current "identifier" numbers configured within TVP Print are:

263   Oki 20+ / Oki 24
1265   HP 4200tn
1   Word Standard (HP Laserjet IIIP)
11   HP 4100tn

Of course, this means of identification is not foolproof. If a new make/model of printer is brought in which, for example, used tray value 11 for its envelope feeder then this would cause TVP Print to malfunction. This is why a Tally T9116D printer needs to use a HP LaserJet IIIP driver, originally TVP Print was configured to work with the Tally but it used the same numbers as the 4200tn printers meaning TVP Print did not know what type of printer it was talking to, and as the Tally needs to print to different trays than the 4200, there was no way for the two to coexist.

Any new multi-tray printers need to be tested for compatibility before being bought in bulk numbers.

Once the TVP Print macro has identified the printer type it sets a string variable with the printer name and two integer variables called trayheaded and trayplain with the correct tray values to be used.

It then calls up a userform called frmprint. This provides the user with the GUI interface. The printer model string variable is displayed and the userform awaits input from the user. Once a selection has been made the appropriate subroutine is called.

The printing subroutines (SingleHeaded and OnePlusOne) convert the string variable of the required number of copies (as entered by the users but set to 1 by default) into an integer value which is used to run though a Do Until loop. As it runs through the loop it configures the page setup using the trayheaded and trayplain variables and prints out the document to those trays.

Finally it configures the page setup back to how it was before the macro was run.

The CTRLALTP and CTRLSHIFTP macros do the same thing but cut out the userform dialogue box. They each have keyboard shortcuts associated with them allowing the user to send a document to print with a minimum of input.

For a full list of the code that makes up TVP Print click here.

To download a zipped copy of Normal.DOT (version 3.7a) containing these macros along with its readme file and a Word file containing this information, click here.

Maintenance and additions.

If changes need to be made then increment the version numbers listed in the Version macro and the frmprint UserForm. The date of modification should also be entered in the Version macro.

If adding printers, find the relevant tray codes (as described earlier) and edit the mPrint module in two places. Firstly, add a line to the array search similar to the 4200tn example below:

If traytype = 1265 Then PrinterModel = "a HP4200tn"

After the array search add related lines similar to the following:

'Set up trays for HP4200tn
If PrinterModel = "a HP 4200tn" Then
trayheaded = 1265
trayplain = 1267
End If

As stated earlier, each printer must have a tray number that is unique in order for TVP Print to correctly identify it. New printers must be vetted to ensure this is the case.


HP4100 and HP4200 printers should be set up with the latest TN versions of the driver. The optional Tray3 paper source (if fitted) must be set in the driver on the server. This is the only option that should be changed on the server. On the printer itself tray 2 must be set as Plain and tray 3 must be set as Letterhead.

Tally T9116D printers must be set up with a HP LaserJet IIIP driver if they are required to work with TVP Print.

Oki 20+ Printers must be set up with the Oki 20+ driver, not the Oki 20n driver.

When using TVP Print with a 4100TN printer, it should report back. Your printer is a 4100TN. If it reports back that your printer is a "Word Standard LaserJetIII/4100", check the driver on the server has been set up with the optional extra Tray 3.

TVP Print currently supports only the following makes/models of printer:

Tally T9116D using HP LJIIIP driver, HP4100/TN, HP4200TN, Oki20+, Oki24 (using dx driver). These are the only multi-tray printers currently in use by Thames Valley Police.

If TVP Print throws up a "Runtime Error 9, Subscript out of range" error, then there is no default printer driver installed for it to interrogate.

If the smiley face or TVP Print buttons are missing and it has been verified that the user is looking at the correct template, ensure that under View / Options both RG Toolbar and TVP Print are selected.

TVP Print tries to apply a page setup to the whole document. If a document has section breaks then the page setup will apply to a single section causing TVP Print to function incorrectly. Remove section breaks from any multi-page document that is needed for use with TVP print.

If TVP Print reports an "Error 5097 There is insufficient memory, Save the document now" then this is a problem between visual basic and the computers DCOM configuration. You can use DCOMCNFG to ensure Word has its identity set to "The Launching User", but it's likely that the workstation will require a reinstall of Word or a re-image. This fault may also manifest itself as a serious Word crash when the macro is run with a dialogue box requesting the user to send an error report to Microsoft.

If you're having problems with an Oki24 (such as certain parts of a page not printing), disable Advanced Printing Features under the drivers Printing Preferences.

If a printer insists on using the American Letter paper size, check the following three locations within the printer driver properties window are all set to A4:

General / Printing Preferences / Advanced

Advanced / Printing Defaults / Advanced

Device Settings

If TVP Print is not working as expected, test the configuration manually. Do this by opening Page Setup and set the document so that page one prints to the tray containing headed paper and subsequent pages print to the tray containing plain paper. Ensure page setup is applying the changes to the Whole Document and not a section (i.e. make sure there are no section breaks). Send the page to print. If it fails to print correctly then the fault is with the printer/driver setup rather than TVP Print (i.e. if you can't print it properly manually then you can't expect it to work when printed automatically). Try recording a macro while setting page setup to see which tray numbers the computer is using. Check the numbers to see if they are valid for your printer.

Did the information on this page help you? If so, please help to fund this site by clicking one of our sponsored ads...