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

Posted on 2012-08-22
Last Modified: 2012-08-26
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,
Question by:c_foster
    LVL 18

    Expert Comment

    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
    Next 'n
    End With
    End Sub

    Open in new window

    Do you need to save this number so that the next time it prints the number is the same?
    LVL 18

    Expert Comment

    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:
    LVL 18

    Accepted Solution

    LVL 76

    Expert Comment

    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
        End If
    End Sub
    Sub FilePrintDefault()
    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
    End Sub

    Open in new window

    The code updates

    Author Closing Comment

    This is the simplest solution.
    Thank you

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Incorrect Word printing error 4 34
    Spacing when using MS Word. 18 38
    html mail signature 8 43
    Word - Access 5 22
    There is a feature provided by MS Word that lets you create an Table of Contents for your Word document automatically. To use this feature for other documents there are two steps involved,   1.  Prepare your document for a table of contents (he…
    Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
    This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
    Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now