Home | Tips | Library | Other Authors | Other WP Sites | Writer's Links | Contact | Site Map | Donate

Barry MacDonnell's
Toolbox for WordPerfect

Macros, tips, and templates for Corel® WordPerfect® for Windows®
© Copyright 1996-2018 by Barry MacDonnell. All Rights Reserved.

Page updated Sep 18, 2018

BATES - Macros that create sequential, fixed-width "Bates" numbers (e.g., 00001, 00002, etc.) with or without preceding/following text material

Download BATES.ZIP - (09/18/18; 95,018 bytes)

Contains 3 macros:

Bates numbering.wcm is compatible with versions WordPerfect 7 and later versions

Bates numbering for multi-page documents.wcm is for WordPerfect 9 and later versions

Bates numbering for pre-printed documents.wcm - written in WordPerfect X9 and should work in other versions

Downloading, Documentation, Modifications, and Support

WordPerfect 11 users: See important information about using macros in the first release of WP11 ( at the top of this page.


BATES.ZIP contains 3 macros:

Bates numbering.wcm — creates multiple copies of a single "master" Avery label or card, log sheet, single-page pre-printed forms, etc., in the printer tray — each stamped with a sequential Bates number.

Bates numbering for multi-page documents.wcm — creates one copy of an on-screen multi-page document with sequential Bates numbers on each page of the document.

Bates numbering for pre-printed documents.wcm creates a separate, adjustable "stencil" document that can be saved and used to print sequential Bates numbers on single- or multiple-page items drawn from the printer tray.

All macros allow specifying the position of Bates numbers and (optionally) the insertion of additional text adjacent to the Bates numbers.

Tip: See also QWIKFILL, which can fill a table column with Bates numbers.

Bates numbering.wcm (v1.10)
(compatible with WordPerfect 7 (c.1996) and later versions)

What is a Bates number?

Bates numbers have a fixed width -- that is, a fixed number of digits defined by the user -- and sometimes contain alphabetical characters. For example:
•  001, 002 ... 999
•  A1001, A1002 ... A9999
•  Ticket # 00000200, Ticket # 00000201 ... Ticket # 99999999

This macro can -

•  create sequential, fixed-width Bates numbers on blank Avery® label or card stock, or

•  stamp the Bates numbers directly on single-page pre-printed forms, letters or legal documents already in your printer's tray, or

•  include the Bates numbers in an existing on screen WordPerfect document, which is expanded by the macro to "x" copies of the original document, with each numbered as specified.

Multiple options are available from a menu, including -

•  ability to place the Bates number stamp precisely where desired (via a special bookmark) on each stamped item;

•  set the total number of digits (the "fixed width") in the Bates number;

•  set the range of the Bates numbers;

•  choose the number of copies of each Bates item;

•  set the font appearance of the Bates number (bold, italic, underlined, small CAPS, or redlined) and/or relative font size (normal, fine, small large, very large, extra large);

•  insert preceding or following text (or both) around the Bates number, optionally separated by hard returns to create 2- or 3-line Bates stamps (see "How does it work?" below).

Some typical uses:
•  Labels ("stickers") to use for labeling items; Avery's 80-label stock works well for this.

•  Labels formatted with other text or graphics (say, your firm's name or logo, or the current date).

•  Small cards for numbered admittance tickets, etc.

•  Numbering the current document (which, when printed, will produce "x" copies of the original, each numbered with a Bates number).

•  Numbering pre-printed documents, such as single-page forms or legal documents, that you load into your printer's tray. (See also the related macro, Bates numbering for pre-printed documents.wcm, below which can also sequentially number multiple-page forms drawn from the printer's tray.)

How does it work?

The macro uses a special bookmark (bates#) that -either- you place on the first label (or on a document's page) -or- you have the macro place it for you at the current cursor location (or at the bottom of the item; for labels, it also can be centered horizontally and vertically).

With this technique you tell the macro exactly where you want the Bates number. It then looks for this bookmark and enters the next Bates number in the sequence; it then goes on to the next label or page and repeats the process. (Those interested in writing macros may want to examine the macro's two nested ForNext() loops that actually generate the Bates numbers.)

When the macro plays, a menu allows entering any preceding (leading) text characters, spaces, and returns, as well as materials that should follow the numbers. For example, you can produce "Bates numbers" like this:

Client Document # A000123 - Confidential

Since you can enter hard returns in these menu text fields (or by checking the HR boxes on the menu), you can easily produce labels like this:
The XYZ Corp.
You can specify the number of digits (the width of the Bates number), the starting and ending numbers, and the number of copies of each numbered item (which will be printed adjacent to one another). You can also specifiy relative font size, and appearance (bold, italic, underlined, and small caps). The macro then creates Bates numbers with these attributes.


¤  If you want to use a Bates number on each page of a single, multi-page document, use the companion macro, Bates numbering for multi-page documents.wcm (below).

[Note that if you play the Bates numbering.wcm macro on a multi-page document, it will place a Bates number just once on the document (just as it would place it just once on a completed, filled sheet of labels/cards), and then make multiple copies of that multi-page document. For example, if you tell it to Start numbering with "1" and End numbering with "80" (the default menu choices), you'll get 80 copies of the same multi-page document, each with a single, incrementing Bates number on them!]

¤  Instructions are included via the Help and How buttons on the macro's main menu. Also, the macro code can be modified in the redlined User Modification Area to set the opening menu's defaults or set a different font for the Bates material.


☼  Need to create a table with custom Bates numbers in one column and another column for annotations? Here's how.

•  Open a new (blank) document. Play the 'Bates numbering' macro to create as many numbered pages as you will need rows in a table. Use the default radio button choice at the top of the macro's menu, and answer 'yes' to the pop up message ('Oops...') about creating a bookmark. You should now have a document with as many pages as numbers.

•  Open Reveal Codes and delete the [Bookmark] code from the top of the document (it is not needed).

•  You will now replace all hard page breaks with hard returns. Click Edit, Find and Replace, Match, Codes. In the Codes dialog that pops up, choose the [HPg] code to Insert in the 'Find' field, and the [HRt] code to Insert in the 'Replace with' field. Close the Codes dialog, and click Replace All in the Find and Replace dialog. Click OK to return to the document, which should now contain a single column of Bates numbers, each separated by a hard return code [HRt].

•  Convert the column of numbers to a table. Click Edit, Select, All to select the column of numbers. Then (in WordPerfect 10+) click -either- Table, Create, OK -or- Table, Convert. For 'Format' choose 'Size column to fit' and for Text Delimters, choose 'Paragraph.' Click OK. You should now have a one-column table with as many rows as you have Bates numbers.

•  Place the cursor in the table, and right-click it. Choose Insert from the context menu that pops up, then click the 'Columns' and 'After' radio buttons. If you set Columns to '1' you will create a table with an empty column to the right of the Bates numbers column. Drag the right-hand table border to size the column to your needs.

☼  Alternative: WordPerfect X6 now includes a Bates macro, which can optionally process multiple documents on disk. You can compare the other options on its main screen: WPX6 Bates macro vs WPToolbox Bates macro. You should test both to see which suits your needs.

Bates numbering for multi-page documents.wcm (v1.02)
(compatible with WordPerfect 9 (c.1999) and later versions)

[Update (May 11, 2012): WordPerfect X6 now includes a version of this macro that can be accessed from its Legal toolbar or its Tools, Legal Tools menu. It can also process multiple files at once. A separate macro can remove the Bates numbers.]


This macro creates sequential, fixed-width Bates numbers (e.g., 0001, 0002) on each page of an existing on-screen multi-page document (or filled Avery® label/card sheet), in any one of 12 locations around the perimeter of the pages. The numbers are inserted in a full-page text box inside a watermark created on each page (or label/card).

When played, the macro creates a copy of the document in a separate window, so that processing will not affect the original. This is the default, but you can change it in the menu. Other menu selections provide for inserting text adjacent to the Bates numbers, similar to the Bates numbering macro described above.

Modifications to default menu (and other) values can be set in the macro's User Modification Area.

[Note: Multiple text boxes on the main document page level are problematic in complex documents; hence, in this macro text boxes inside watermarks are used instead.]


The macro can be played on any normal on-screen document, or on a filled sheet of labels/cards on your screen. [The latter must already be expanded on screen to show several (or all) labels/cards on the physical sheet of paper stock, not just the first one. To use Bates numbers on a single, "master" label/card and have the remaining labels/cards created automatically, you should use the companion macro, Bates numbering.wcm.]


☼  Modifications to default menu (and other) values can be set in the User Modification Area. For example, you can set -

•  a new font type for each section of the Bates material (text and numbering); this might be useful if the text or Bates number is a bar code font, or you simply want to change the appearance of optional text, perhaps because it is on a separate line from the Bates number;

•  default menu values for (optional) text that should precede or follow the Bates number.

☼  This macro can be used to create a second page numbering system on the same pages, typically for a different page number sequence than that used by the WordPerfect page numbering system. Since the macro works by typing an incremented number into the document on each page, it does not depend on the built-in page numbering system.

☼  If you do not want to use leading zeros you can simply "comment out" the command Type("0") at about line 397 in the macro's code by placing two slash marks (//) in front of it. This command is in the section entitled "Create the Bates number for the current page." Then click the Options button on the macro toolbar and save the macro under a different name so that you can have both versions handy.

Bates numbering for pre-printed documents.wcm (v1.0)New! symbol
(written in WordPerfect X9 (c.2018) but should work in other versions)


In a hurry? You can just extract the macro from the ZIP file, put it in your Default or Supplemental macro folder, and play it. It will quickly create a new, separate, on-screen multi-page document without printing anything. Scroll through it to see how the Bates numbers were entered on each page.

But if you want to better understand its purpose, operation, and options, read on.


This macro creates sequential, fixed-width Bates numbers (e.g., 00001, 00002) in a separate on screen "stencil" document that you can later use to stamp the Bates numbers on pre-printed single-page or multi-page items loaded in the printer's tray.

[NOTE: This macro is not designed for Avery labels, business cards or similar multiple-items-per-sheet paper. Rather, it can be used to print Bates numbers on separate items loaded in the printer tray. For the former tasks see other Bates macros above.]

The Bates starting number, number of pre-printed documents and document pages, position of numbers, adjacent text (if any), and other variables can be specified in a pop up menu at run time.

specifications are set in the User Modification Area at the top of the macro's main code. Please note there are several settings so be sure to read each of them carefully. If you often use the same settings the pop up menu (both basic and extended) can be switched off in that modification area as well.

For example, by default the Bates number location will be at the top of the pre-printed items when the stencil is printed, at one of three user-chosen locations: Left, Centered, or Flush Right between the left and right page margins. Custom page margins can also be set for the marco to use, which is an easy way to simply and effectively adjust these three relative-to-margins locations. (Or you can just drag the stencil document's margin guidelines later to reposition them.)

Optionally, the Bates numbers can be placed at exact locations by specifying the distance from the top and left edges of the physical pages -- even to near the bottom of the pages -- with an accuracy of 3 decimals. This can be useful if you need to stamp Bates numbers in a specific area of a pre-printed form (or if the above default locations are not accurate enough for the task).


[1] Optional (but recommended).
Set your desired default specifications -- e.g., whether or not to display a menu, the maximum number of pre-printed documents to process, the number of pages per document, the relative location of the Bates number, its starting (base) number, and other options -- in the User Modification Area at the top of the macro's main code. These specifications also set ("feed") the macro's menu with your preferred default choices.

[2] Play the macro.
By default, pop up menus appear where you can adjust various settings. When you finish with the menus the stencil document should be quickly created on your screen. You can save the document for future use. (Note: An option in the User Modification Area lets you skip menus when the macro runs. In that case the default specifications in that modification area will be used to create the stencil.)

[3] When you are ready, load the printer with the pre-printed items.
[Or you can use plain paper to test the Bates numbering using a short print run (next step).]

[4] Print the stencil document with File, Print.
As with any WordPerfect document, before starting the print run you can specify the Full stencil document to print, or just a single page or a range of pages. Printing a specific page (e.g., using Current page for the page where the cursor is positioned) or a range of pages can be useful to test the operation or to re-print items that might have been damaged. When you print the stencil it will stamp its Bates numbers on the corresponding pre-printed items as they are drawn from the printer tray.


Depending on your Print choices for the stencil document, the Bates number that begins on the specified File, Print page(s) for the stencil document will be the number that will be stamped on the first item pulled from the printer tray. While this may seem obvious it can be easy to forget and might impact proper Bates numbering.

If you choose File, Print, Full document this should not be an issue since you will start printing with the first page of the stencil document and each item drawn from the tray will correspond to each stencil page. Similarly if the cursor is located on a particular stencil page and you choose File, Print, Current page you will print just that page with its unique Bates number.

However ... if you specify a particular range of pages (e.g., File, Print, Pages: 48-50) further into the stencil document you should first ensure that the Bates numbers on those particular pages are actually the ones you need printed. (Hint: Use Edit, Go To, Page.)  A change in Bates starting number will put Bates numbers on those pages that probably differ in numerical sequence from their stencil page numbers, and this might be confusing when specifying a range at print time.


The macro first creates a new blank document with File, New to help ensure no other text or format codes exist in it. It then adds several page formatting codes, along with the current range of sequential Bates numbers at the chosen location, one Bates number per page (along with any optional leading and/or following text), for as many pages as were set by you on the macro's menu. Note: Along with other items, your preferred default number of pages can be specified in the macro's User Modification Area.

Creating a multi-page stencil document is very quick since it contains just Bates numbers, perhaps some optional text strings, and a minimal number of format codes. Even a very large number of pages in that stencil document takes very little memory and -- if the document is saved -- very little disk space.

(Compared to macro code that does not use a stencil but instead rapidly generates a large number of formatting and print commands to directly print on items in the tray, the stencil document as used here does not automatically print anything. This should help prevent timing or feedback issues at print time between program and printer since the program will take care of them when you print the stencil -- as it does when printing any large multi-page document.)

Besides providing automation to creating sequential Bates numbers at a variety of locations, there's another advantage to using this macro:

If each document in the printer's tray is made up of more than one page (and you have specified the number of such pages-per-document) the macro will use that information to automatically add extra pages to the stencil document so that it corresponds, one-to-one, to the pre-printed document pages.

Moreover, you can have the macro stamp the Bates number on just the first page of each multi-page document or, using the same Bates number, on all pages of that particular document. Alternatively, simply set the pages-per-document to 1 if you want every sheet drawn from the printer tray to have a unique Bates number.


•  Since the stencil document will contain Bates stamps for as many pages as you specified, you can save the document for future use. This might be handy if you need to re-print a range of items.

•  Before printing numbers on your actual pre-printed documents you might feel more comfortable printing a small test run on plain paper. Just print the first page of the stencil document on plain paper (e.g., File, Print, Current page). Then you can use that printout to see where the numbers appear and compare this location to the area on the pre-printed documents that you want to stamp with Bates numbers.

•  Bates numbers and any optional text will be printed on one line (no wrapping), so keep any such adjacent text strings reasonably short, and be sure to test it by printing a single page (e.g., File, Print, Current page). You can try using a smaller font to help accomodate a little more text.

•  If needed, play the macro again and adjust the print settings on the pop up menu (or in the macro's User Modification Area, which "feeds" the menu's default values). It will create another stencil document with the new settings.

•  Since the stencil document is a regular WordPerfect document you can also edit it before printing. For example, you could add a watermark to it, which will then print on every page drawn from the printer tray. (For more on watermarks: https://wptoolbox.com/tips/HeadFootWM.html.) Or you can double click on the stencil document's [Paper Sz/Typ] code in Reveal Codes to change the paper size before printing. Or set new page margins on the first page. The edits should carry over to subsequent pages.

•  By setting page margins for a given page size to a larger amount, you can "squeeze" the printable area smaller to allow printing the Bates numbers on smaller sheets of paper. Or use the "relative to page edges" settings to specify an exact location. (Obviously, be sure to thoroughly test this on plain paper.)


•  General information

As with any WordPerfect document, you can open the macro file for editing, typically with Tools, Macro, Edit.

Following a section of comments at the beginning of the macro commands (i.e., most of the material you are reading here) you will see a redlined User Modification Area. Instructions there describe how to set various menu defaults -- including an option to not show any menu (or just show a basic version). This can be useful to enable once you gain experience with the macro and you typically use the same preferred defaults.

These default settings precede the code that displays the menu at run time, so they also "feed" the menu with your preferences first. If you prefer a menu, any changes you make on the menu at run time take precedence over the modification settings (the menu is "downstream" from the modification area) when the macro does its job.

If you make changes in that modification area, you will want to save the macro with the Save & Compile button on the macro toolbar that should be visible -- or just use File, Save from the program's main menu.

•  Tweaking the Bates number placement

Because the macro cannot "see" the physical size or contents of the pre-printed pages in the printer tray, some print jobs might need your instructions on exactly where to place the Bates stamp on the pre-printed pages.

The most accurate way to do this for any page location is to set the vRelativeBatesLocation... variable to "Edges" and then set specific vertical and horizontal dimensions. The macro will use the macro command equivalents of WordPerfect's Format, Typesetting, Advance. Default values for this and other information are found in the macro's User Modification Area.

On the other hand if you are using one of the three relative-to-page-margins settings you can adjust the top and side page margin dimensions on the menu -- or simply edit the resulting stencil document and drag the top and side dotted margin guideline a small amount. Either way, this will cause the Bates material to move accordingly.

•  Tweaking the page size

As written, the stencil document is set to create Letter size (8.5 x11.0") pages for both Portrait or Landscape. (Portrait orientation is the default.)

If you use another paper size you can modify the two PaperSizeSelect() commands in the ForNext() loop in the main macro code.

Or -- as mentioned in the Tips above -- you can simply change the stencil's paper size before printing it (using File, Page Setup on the first page).

[Sorry about any inconvenience but there are too many different printers and paper sizes to code the macro to accommodate all possibilities.]

Page Top