Share via

Creating an Invoice in Word and adding a sequential number

Anonymous
2019-03-25T15:13:44+00:00

I really would like to know how to simply create a document in Word (already done that part) that has a place where the invoice number will be displayed but will increase by 1 each time a new document has been createdie 4000, 4001, 4002 etc

How is this done in easy steps please.

I have tried looking on the web and some details say to use bookmarks and macros but I am not able to follow the details properly for it to work so any help would be great

Thanks

John

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
  1. Doug Robbins - MVP - Office Apps and Services 322.9K Reputation points MVP Volunteer Moderator
    2019-03-30T21:16:16+00:00

    It sounds like you are probably using File>Open and opening the template, rather than using File>New and then selecting the template as the basis of the document that you want to create.

    An easy way to do that is to add the New Document or Template command to the Quick Access Tool bar as it will take you directly to the Templates folder in which you can selecte the template with the result that a new document will be created from it, which will trigger the running of the AutoNew macro in the template.

    4 people found this answer helpful.
    0 comments No comments

11 additional answers

Sort by: Most helpful
  1. Doug Robbins - MVP - Office Apps and Services 322.9K Reputation points MVP Volunteer Moderator
    2019-05-17T11:14:47+00:00

    Use the following code

    Dim InvoiceNum As Long

    If GetSetting("Invoices", "Numbers", "Number") = "" Then

        InvoiceNum = 1

    Else

        InvoiceNum = GetSetting("Invoices", "Numbers", "Number") + 1

    End If

    SaveSetting "Invoices", "Numbers", "Number", InvoiceNum

    With ActiveDocument

        .Variables("InvoiceNumber") = Format(InvoiceNum, "00#")

        .Range.Fields.Update

        .SaveAs FileName:="F:\SALES RECEPITS VALUATIONS PS JEWELLERY\Invoices 2019" & Format(InvoiceNum, "00#")

    End With

    Instead of using a bookmark where you want the Invoice Number to appear, at that location insert a { DOCVARIABLE InvoiceNumber } field, using CTRL+F9 to insert the field delimiters { } and use ALT+F9 to toggle off their display

    4 people found this answer helpful.
    0 comments No comments
  2. Jay Freedman 207.5K Reputation points Volunteer Moderator
    2019-05-17T19:47:09+00:00

    The simple way to insert the field in the document is to go to Insert > Quick Parts > Field, select DocVariable in the list of field names, and type InvoiceNumber into the Field Properties box:

    If you have already run the macro so that the document has a variable named InvoiceNumber, that number will appear at the cursor location. If you haven't run the macro yet, this message appears instead:

    In that case, run the macro and then click on the error message and press F9 to update the field.

    The Field dialog inserts the same field that Doug described, which has the code (visible when you press Alt+F9)

    { DOCVARIABLE  InvoiceNumber  }

    (By default the dialog has a check mark in the box for "Preserve formatting during updates", which adds the switch \* MERGEFORMAT to the field code; that's entirely optional.)

    2 people found this answer helpful.
    0 comments No comments
  3. Anonymous
    2019-03-26T15:35:01+00:00

    Thank you for the links - however I have seen these on the web but I am no clearer - sorry!

    1 person found this answer helpful.
    0 comments No comments
  4. Suzanne S Barnhill 277.1K Reputation points MVP Volunteer Moderator
    2019-03-25T16:40:12+00:00
    1 person found this answer helpful.
    0 comments No comments