View Single Post
 
Old 05-16-2014, 06:06 AM
Mark Paterson Mark Paterson is offline Windows 7 64bit Office 2007
Novice
 
Join Date: May 2014
Location: Kingston Ontario Canada
Posts: 2
Mark Paterson is on a distinguished road
Default Sequentially numbered copies of multi-page word document

I have a 25 page Word 2007 document that requires the serial number to appear on each page. Is it possible to bookmark each location to have a sequential serial number auto generate for each printed copy? We are currently stamping the serial number on each page of the inspection record. I found the following Macro but it only picks up the first bookmark.
Code:
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

Last edited by macropod; 05-16-2014 at 04:06 PM. Reason: Added code tags & formatting
Reply With Quote