Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-16-2014, 06:06 AM
Mark Paterson Mark Paterson is offline Sequentially numbered copies of multi-page word document Windows 7 64bit Sequentially numbered copies of multi-page word document Office 2007
Novice
Sequentially numbered copies of multi-page word document
 
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
  #2  
Old 05-16-2014, 10:30 AM
Charles Kenyon Charles Kenyon is offline Sequentially numbered copies of multi-page word document Windows 7 64bit Sequentially numbered copies of multi-page word document Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,454
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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.
Reply With Quote
  #3  
Old 05-16-2014, 11:22 AM
Mark Paterson Mark Paterson is offline Sequentially numbered copies of multi-page word document Windows 7 64bit Sequentially numbered copies of multi-page word document Office 2007
Novice
Sequentially numbered copies of multi-page word document
 
Join Date: May 2014
Location: Kingston Ontario Canada
Posts: 2
Mark Paterson is on a distinguished road
Default

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.
Reply With Quote
  #4  
Old 05-16-2014, 04:34 PM
macropod's Avatar
macropod macropod is offline Sequentially numbered copies of multi-page word document Windows 7 32bit Sequentially numbered copies of multi-page word document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,341
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply

Tags
auto numbering



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sequentially numbered copies of multi-page word document Continuous Page Numbers with Multi-sectioned document are not working. Morningside Word 4 05-19-2014 01:18 PM
Sequentially numbered copies of multi-page word document Sequentially numbering a document UniAdmin Word VBA 1 02-21-2013 07:25 PM
Sequentially numbered copies of multi-page word document Insert multi page pdf into Word 2010 document TimTDP Word 1 04-18-2012 04:22 AM
Sequentially numbered copies of multi-page word document 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

Other Forums: Access Forums

All times are GMT -7. The time now is 03:31 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft