Share via

How to create sequentially increasing invoice numbers and file name with each new document in word

Anonymous
2023-04-29T08:15:04+00:00

Hi!

I am trying to create a sequentially increasing file number and invoice number for each new document created.

For example,

Within my document in the header, I will have SVC0000.

and everytime i open it up as a new document, I would like the number to increase by one to SVC00001, so on and so forth. With the document file name following it, automatically renaming the document as SVC0001.

If anyone has a solution for me it would be much appreciated! Thanks!

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

5 answers

Sort by: Most helpful
  1. Anonymous
    2023-05-03T11:37:38+00:00

    Hi, I dont seem to be able to create a field property, when i click onto SEQ, it does not prompt me to set any "Start at" etc.

    Do assist as i think we might be going somewhere with this.

    Thanks

    20+ people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2023-04-29T08:54:09+00:00

    Hi,

    I'm Sneha and I'd be happy to help you out with your question. Sorry for the inconvenience caused.

    To start, we'll use Word's field codes to create the invoice number. Here are the steps:

    1. Open a new Word document.
    2. Go to the "Insert" tab in the ribbon and click on "Quick Parts" -> "Field."
    3. In the "Field" dialog box, select "Seq" from the list of field names.
    4. In the "Field properties" section, set the "Name" field to "InvoiceNumber" (or any name you prefer).
    5. Set the "Start at" field to "1" and "Increment" field to "1".
    6. Click "OK" to close the dialog box and insert the field code into the document.

    Now, to display the invoice number in the header, follow these steps:

    1. Go to the "Insert" tab and click on "Header" -> "Edit Header."
    2. Place your cursor where you want the invoice number to appear and then go to "Insert" -> "Quick Parts" -> "Field."
    3. In the "Field" dialog box, select "DocProperty" from the list of field names.
    4. In the "Field properties" section, select "InvoiceNumber" from the list of properties.
    5. Click "OK" to close the dialog box and insert the field code into the header.

    To automatically rename the file with the invoice number, we'll need to add a macro. Here's how to do that:

    1. Go to the "Developer" tab in the ribbon (if you don't see it, you may need to enable it in Word's options) and click on "Visual Basic."
    2. In the Visual Basic editor, go to "Insert" -> "Module" and paste the following code:

    Sub AutoOpen() 'Update invoice number ActiveDocument.Fields.Update 'Get the invoice number from the document property Dim invoiceNumber As String invoiceNumber = ActiveDocument.CustomDocumentProperties("InvoiceNumber"). Value 'Rename the file Dim fileName As String fileName = "SVC" & invoiceNumber & ".docx" Name ActiveDocument.FullName As fileName End Sub

    1. Save the macro and close the Visual Basic editor.
    2. Save the document as "SVC0000.docx" (or any starting number you prefer).

    Now, each time you open the document, the invoice number will automatically increment by one, and the file name will be updated to match the new invoice number.

    If you have any other questions or need assistance with anything, please don't hesitate to let me know. It will be my pleasure to Assist you.

    Best Regards, Sneha

    Give back to the community. Help the next person with this problem by indicating whether this answer solved your problem. Click Yes or No at the bottom.

    10+ people found this answer helpful.
    0 comments No comments
  3. Suzanne S Barnhill 277.1K Reputation points MVP Volunteer Moderator
    2023-04-29T12:03:44+00:00
    5 people found this answer helpful.
    0 comments No comments
  4. Charles Kenyon 166.5K Reputation points Volunteer Moderator
    2023-05-03T11:55:11+00:00

    Use Graham Mayor's work or replicate it yourself.

    Automatic numbering of Word documents by Graham Mayor, MVP

    You really want to be using a Template, not a document, for this.

    Templates in Microsoft Word

    3 people found this answer helpful.
    0 comments No comments
  5. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more