Call : 381-18-529-373

Printing Serial Numbers in Word 2010

When printing large number of copies of one form, there is a possibility that you’ll need Serial Numbers. In order to print incremented serial numbers in Word 2010, do the following :
1. Goto View -> Macro -> View Macros

2. Create Macro


3. Add following code to the macro :

[sourcecode language=”vb”] 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 [/sourcecode]
Save the file as Macro enabled (File type drop down when saving)
4. Place the cursor on the page where you want Serial to appear.
5. Goto Insert -> Bookmark

 

6. Name the bookmark “Serial”
7. Go back to View -> Macros -> View Macros
8. Run Your macro
9. Select number of copies