Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, 2016, 2019, 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: Using Sequential Document Serial Numbers.

Using Sequential Document Serial Numbers

Written by Allen Wyatt (last updated July 31, 2021)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, and 2021


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 create the macro that will control the changing of the serial number and the printing of your document. You can use the following macro:

Sub MySerial()
    Dim docCurrent As Document
    Dim rSerial As Range
    Dim iSerialNum As Integer
    Dim sTemp As String
    Dim iCopies As Integer
    Dim iCount As Integer

    Set docCurrent = Application.ActiveDocument
    Set rSerial = docCurrent.Bookmarks("Serial").Range

    ' Get the starting number. Note that the serial number
    ' needs to consist only of digits (no leading letters or
    ' symbols) in order for the Val function to work properly.
    iSerialNum = Val(rSerial.Text)

    ' Get the number of copies required
    sTemp = InputBox("How many copies?", "Print Serialized", "1")
    iCopies = Val(sTemp)

    For iCount = 1 To iCopies
        ' Print the document
        docCurrent.PrintOut Range:=wdPrintAllDocument
        ' Increment the serial number
        iSerialNum = iSerialNum + 1
        ' Convert to formatted number (with leading zeroes)
        ' and put back into the document.
        sTemp = Format(iSerialNum, "00000")
        rSerial.Text = sTemp
    Next iCount

    ' Reset the bookmark, since the updating procedure
    ' wipes out the old one.
    docCurrent.Bookmarks.Add Name:="Serial", Range:=rSerial
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. The macro assumes that the serial number will be something like "00010" or "00123", with the leading zeroes. Thus, your bookmark (Serial) should reference the five digits that constitute your serial number.

If you want your serial number to be formatted differently, then you'll need to change the macro. Don't forget that the macro assumes the serial number can be converted directly to a value that can be incremented. So, if your bookmarked serial number starts with a letter (such as "Copy 001"), that will never increment properly. Instead, bookmark only the numeric portion.

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.

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 (9540) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, and 2021. You can find a version of this tip for the older menu interface of Word 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

Macro-Inserted AutoText Doesn't Set Style

Inserting AutoText from a macro can give unwanted results, particularly when it comes to any style that may be stored ...

Discover More

Renaming a Toolbar

Create your own toolbars and, at some point, you may have a hankering to change their names. Here's how you can make the ...

Discover More

Vertical Alignment of an Inline Graphic

Word allows you to insert graphics in two ways: either inline or floating. If you use inline graphics, you may want to ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 365 applications with VBA programming. Written in clear terms and understandable language, the book includes systematic tutorials and contains both intermediate and advanced content for experienced VB developers. Designed to be comprehensive, the book addresses not just one Office application, but the entire Office suite. Check out Mastering VBA for Microsoft Office 365 today!

More WordTips (ribbon)

Printing Summary Information

Word automatically maintains a number of properties for each document you create. As part of those properties you can ...

Discover More

Printing Personalized Copies of a Document

Need to have a series of documents customized for individual users? Mail merge may be overkill, but the macro presented ...

Discover More

Remembering Copies to Print

If you routinely need to print more than one copy of a document, you'll love the ideas presented in this tip. There's ...

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 1 + 4?

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.