![]() |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
Using the Add-In on Graham Mayor's site, you could put the number into document variables and use a DOCVARIABLE field in the file to display it wherever you wanted.
|
|
#3
|
|||
|
|||
|
Hello Graham,
Thank you for your expeditious response to my query however, it does not appear that the add-on will allow me to place a "bookmark" at various locations within the 25 page document such that each page will be sequentially serialized automatically upon printing (run on sentence?). Sorry. |
|
#4
|
||||
|
||||
|
If you place your Serial # in the page header or footer it will automatically appear on every page in that Section or any linked Section.
The question remains though, as to how you will control the numbering. There are different ways of doing this and each has advantages & disadvantages. For example, you could use a master copy or template that has a serial # that gets updated each time it's opened. Great for invoice production and the like, but not so good if you're using a document and its number changes every time you open it to read it. In that case a template might be better - you can open the resulting document without its number changing every time. Alternatively, you could use a macro that intercept's the document's printing. That means the master document has to be updated every time a print is made. That could be done by using a FilePrint macro to intercept the standard print functions, so the updating can be assured. Your macro takes a different approach, which relies on the user choosing to use your macro. As for maintaining the update sequencing, I'd suggest storing the serial #s in either a custom document property or an external file, so it can be retrieved for the next print. Alternatively, if there's nothing else in the header or footer, you could just as easily store it there (you could also do so even if there's other content, but you need extra code to allow for that). Using an external file that's updated automatically by the macro means it doesn't matter whether the user remembers to save the document on closing. Alternatively, the print macro could save the document with the updated properties upon printing. In any event, you don't need a bookmark. You can use either a custom document property or a value stored in the header or footer. If you use a custom document property, all you need to display the serial # anywhere in the document is a DOCPROPERTY field at that location.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
| Tags |
| auto numbering |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Continuous Page Numbers with Multi-sectioned document are not working.
|
Morningside | Word | 4 | 05-19-2014 01:18 PM |
Sequentially numbering a document
|
UniAdmin | Word VBA | 1 | 02-21-2013 07:25 PM |
Insert multi page pdf into Word 2010 document
|
TimTDP | Word | 1 | 04-18-2012 04:22 AM |
Multiple sequentialy numbered copies of one page
|
Roger1941 | Word VBA | 1 | 01-24-2011 03:26 PM |
| varying orientation on a multi-page document??? | imimin | Word | 1 | 08-24-2009 12:12 PM |