Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Using Sequential Document Serial Numbers.

Using Sequential Document Serial Numbers

Written by Allen Wyatt (last updated November 10, 2018)
This tip applies to Word 97, 2000, 2002, and 2003


2

If you have a need to create serial numbers in your documents and they are very simple in nature, you can do so using a macro. This approach to serial numbers is great if your serial numbers are sequential (1, 2, 3, etc.) or regular in their incidence (3, 5, 7, etc.).

To begin, you should enter the macro that will control the change of the serial number and the printing of your document. You can use the following macro:

Sub MySerial()
    Dim rngSerialLocation As Range
    Dim intSerialNum As Integer
    Dim strSerialNum As String
    Dim docCurrent As Document
    Dim intNumCopies As Integer
    Dim intCount As Integer

    ' set ref to current active doc
    Set docCurrent = Application.ActiveDocument
    ' set ref to the bookmarked serial number
    Set rngSerialLocation = docCurrent.Bookmarks("Serial").Range

    ' get the starting number
    intSerialNum = Val(rngSerialLocation.Text)
    ' get the number of copies required
    intNumCopies = Val(InputBox$("How many Copies?", _
      "Print Serialized", "1"))

    For intCount = 1 To intNumCopies
        ' print the document
        docCurrent.PrintOut Range:=wdPrintAllDocument
        ' increment the serial number
        intSerialNum = intSerialNum + 1
        ' put into formatted version
        strSerialNum = Format(intSerialNum, "00000")
        ' stuff into proper place
        rngSerialLocation.Text = strSerialNum
    Next intCount

    ' reset the bookmark, since the updating procedure
    ' wipes out the old one
    docCurrent.Bookmarks.Add Name:="Serial", _
      Range:=rngSerialLocation
End Sub

There is only one prerequisite to using the macro: you need to make sure that your document contains a bookmark named Serial. This bookmark should reference the serial number in your document, as you want it to appear in the first printed document. (When you are through running the macro, you can save the document and the serial number will be ready for the next time you want to use it.)

The macro also assumes that your serial number consists primarily of some numeric value that changes with each iteration. You can modify the incrementing of the serial number, as well as its formatting, in the For...Next loop within the macro.

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 (1747) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Using Sequential Document Serial Numbers.

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

Fixing Odd Sorting Behavior

When you sort data that contains both numbers and text, you may not get exactly the result that you expected. To know ...

Discover More

Changing the User Name in Existing Comments

Want to change the name that Word associates with various comments previously added to your document? Here are some ideas ...

Discover More

Getting the Name of the Parent Workbook

If you need to insert into a cell the name of the workbook in which a worksheet is contained, you can use the CELL ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More WordTips (menu)

Adding a Horizontal Watermark with a PostScript Printer

In Windows, printer drivers translate formatting into a printer control language, like PostScript, that the printer ...

Discover More

Printing Show/Hide Characters

Non-printing characters are very handy to view when editing a document. But what if you want those characters to no ...

Discover More

Non-Printing Hyperlinks

Karen is having problems getting hyperlinks to print in a document on her home computer. There are only a limited number ...

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 two more than 7?

2020-07-18 16:08:09

Philip

Worked great. Just be careful the last thing you printed was only one copy or it will try and print that many of each serial number. All I had to do was close all word docs and open it again and it worked. Also if you are printing a large number of them it will start in the middle of the serial numbers and print a few then start at the beginning and print the rest skipping the ones it already printed. Is it possible to make it print high to low order so lowest is on top at the end?


2020-01-18 04:38:48

ADO

I found this very useful, thank you.

Would like to learn how to modify it if I apply it to multiple bookmarks,

say I want to make a hundred of lucky draw tickets, each ticket would need a pair a serial number to validate.

And there are 3 redundant copies squeezed in a page(to save paper, and ticket usually are smaller than a A4)

On the page it would have
1, 1,
2, 2,
3, 3.

Could I simply apply +3 each print and how should I make the program work?

Thanks.


This Site

Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon 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.