• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 879
  • Last Modified:

Adding a sequential "Order number" to a one page MS Word form

I'm in the process of preparing a one-page order form for a charitable drive.  I would like to include a sequential "order number" to the one page form that would increment with each page i print.  This way i can ask particpants to include the order number on the memo line of their checks and be able to match the checks to the order form to ensure delivery of the proper product.  

I found the SEQ information in MS Word 2007, however, on the 5 test pages i printed, they all came out with an order number of 1 instead of 1 on the first printed page, 2 on the second printed page, etc.  

Does anyone know if this is possible? And if so, how?

Maximum points because i need this fast.  

Thank you,
Carolyn
0
c_foster
Asked:
c_foster
  • 3
1 Solution
 
RartemassAuthor, martial arts coach, IT ConsultantCommented:
You would need a script for this.
The below should get you started. It assumes document is one page long, has one section and one footer type.
It increments the page number. If you want it to increase beyond 100, change that value to the highest number you want.

<pre>Public Sub PrintDocumentWithIncrementingPageNumbers()
Dim n As Long
With ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).PageNumbers
'Increment page number:
For n = 1 To 100
.StartingNumber = n
ActiveDocument.PrintOut
Next 'n
End With
End Sub
</pre>

Open in new window


Do you need to save this number so that the next time it prints the number is the same?
0
 
RartemassAuthor, martial arts coach, IT ConsultantCommented:
You could also use a template with a macro for this that when a new document is created from it, the number increases. This link should aid with that:
http://word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm
0
 
RartemassAuthor, martial arts coach, IT ConsultantCommented:
0
 
GrahamSkanCommented:
You could use a document property, a document property field (DocProperty) and this macro set.

Option Explicit

Sub FilePrint()
    Dim dlg As Dialog
    Set dlg = Dialogs(wdDialogFilePrint)
    If dlg.Display = -1 Then
        dlg.Execute
        SetOrderNo
    End If
End Sub

Sub FilePrintDefault()
    ActiveDocument.PrintOut
    SetOrderNo
End Sub

Sub SetOrderNo()
    Dim prop As DocumentProperty
    For Each prop In ActiveDocument.CustomDocumentProperties
        If prop.Name = "OrderNo" Then
            prop.Value = prop.Value + 1
            Exit For
        End If
    Next prop
    If prop Is Nothing Then
        Set prop = ActiveDocument.CustomDocumentProperties.Add("OrderNo", False, msoPropertyTypeNumber, 1)
    End If
    ActiveDocument.Fields.Update
End Sub

Open in new window


The code updates
0
 
c_fosterAuthor Commented:
This is the simplest solution.
Thank you
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now