Printing multiple pages from template

D

danep

Hi all,

Basically, I have a form that I'm making in Word 2007 that has an
index (i.e. a counter, not the kind of index you find at the back of a
book) that I would like to increment every time it is printed. My
current solution is to use a page number, and create dozens or
hundreds of pages as needed so that each one will have a unique number
on it.

Is there a simpler way to do this? I.e. just have a one page
template, and you can choose to print multiple copies or multiple
pages of that template, and each copy will its own page number?

Sorry if that's confusing; any help is appreciated, my current
solution to this is pretty ugly...
 
G

Graham Mayor

http://www.gmayor.com/automatic_numbering_documents.htm demonstrates how to
produce sequentially numbered documents from an ini file or registry entry.
The macro does work in Word 2007, so all that is required is to change from
an 'invoice number' to a 'print number' eg

Sub AddNoFromINIFileToHeader()
Dim SettingsFile As String
Dim Order As String
Dim sView As String
'Save invoice number in the Word startup folder.
SettingsFile = Options.DefaultFilePath(wdStartupPath) & "\Settings.ini"
'or the Workgroup folder
'SettingsFile = Options.DefaultFilePath(wdWorkgroupTemplatesPath) &
"\Settings.ini"

Order = System.PrivateProfileString(SettingsFile, _
"Print Number", "Order")
If Order = "" Then
Order = 1
Else
Order = Order + 1
End If

System.PrivateProfileString(SettingsFile, "Print Number", _
"Order") = Order
sView = ActiveWindow.View 'store the current view
With ActiveWindow
.View = wdPrintView 'set the document view to print layout
.ActivePane.View.SeekView = wdSeekCurrentPageHeader
With Selection
.WholeStory 'select any existing header text
.Delete Unit:=wdCharacter, Count:=1 'and delete it
.Font.Name = "Arial"
.Font.Bold = True
.Font.Italic = False
.Font.Size = "10"
.ParagraphFormat.Alignment = wdAlignParagraphRight
.TypeText Text:="Print number: " & Format(Order, "#")
End With
.View.SeekView = wdSeekMainDocument
.View = sView
End With
Application.PrintOut FileName:=""
End Sub
http://www.gmayor.com/installing_macro.htm

The above macro will put the text
Print number: n
(where n is the next number) in the top right corner of the header,
formatted as 10 point Arial Bold then prints the document. If saved in your
document template you could intercept the print routine by calling the macro
Sub FilePrintDefault() then when the document is printed the number would be
incremented, but personally I would prefer to add a button to a custom
toolbar in the document template to run the macro as it stands.

You can change the printed text and its position by editing the relevant
parts of the macro, and you can reset the number by editing the ini file in
notepad.


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top