Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, and 2013. 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.
by Allen Wyatt
(last updated May 16, 2015)
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.
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, and 2013. You can find a version of this tip for the older menu interface of Word here: Using Sequential Document Serial Numbers.
Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!
You may want to use a macro to process and then print your document. Part of that printing may involve specifying which of ...Discover More
Do you want to transfer fonts from one computer system to another? It is relatively easy to do, but there is one important ...Discover More
Print your document with lots of space between each line by triple spacing it! Here are some quick and easy steps for getting ...Discover More
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
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.