How to Create Sequential Invoice Numbers and Auto-Rename Word Files
Question details
The user wants to generate sequential invoice numbers using dynamic fields and automatically rename the saved document based on the generated invoice number.

- Product
- Word
- Device & OS
- not provided
- Scenario
- Creating a standardized invoice template that automatically increments its invoice number upon creation and saves the file with the corresponding formatted name.
- Observed behavior
- The default SEQ field dialog does not explicitly prompt for a starting value, and native document features cannot automatically rename files without the use of a VBA macro.
Ensure the Developer tab is enabled in your word processor to access the VBA editor, and be prepared to save your master template as a Macro-Enabled Document (.docm).
Use Field Codes to Set a Sequential Invoice Number
Manually define the SEQ field code to bypass the dialog limitations and specify the exact starting number for your invoices.
Microsoft Word uses SEQ (Sequence) fields to generate sequential numbers. When the Quick Parts dialog doesn't offer a starting value option, you can easily set it by modifying the field code directly in the document.
Press Ctrl + F9 on your keyboard to insert a set of blank field brackets { }.
Inside the brackets, type the code: SEQ InvoiceNumber \r 1 to set the starting sequence number to 1.
Press F9 while your cursor is inside the field to update it and display the starting number.
To update all fields in the document simultaneously (e.g., for the next invoice), press Ctrl + A to select all text, then press F9.

Automatically Rename and Save the Invoice with a VBA Macro
Use a VBA macro to extract the generated sequence number, apply a specific format, and save the document automatically.
Create Auto-Incrementing Templates in WPS Writer
WPS Writer fully supports advanced field codes and document properties, allowing you to easily build auto-incrementing invoice templates with a clean, highly efficient interface.
- 1. Create an invoice layout: Open WPS Writer, start a new document, and design your invoice layout or open an existing template.
- 2. Insert the field code: Press Ctrl + F9 to generate field brackets and type your sequence logic, such as SEQ Invoice \r 1.
- 3. Update the invoice number: Right-click the field code and select 'Update Field' or simply press F9 to display the generated number.
- 4. Save as a template: Go to Menu > Save As, and choose to save your document as a template (.dotx or .dotm) for standardizing future billing.

Frequently Asked Questions
How do I increment the sequence number for my next invoice?
When you open a new document based on your invoice template, select the SEQ field (or press Ctrl+A to select the entire document) and press F9. The field will evaluate the previous numbers and automatically increment to the next value.
Why is my document showing the code instead of the invoice number?
You are likely viewing the raw field codes instead of their results. Press Alt+F9 on your keyboard to toggle between displaying the field codes (e.g., { SEQ InvoiceNumber \r 1 }) and the actual generated numbers.
Can I add a text prefix to my sequential invoice numbers?
Yes. You can simply type regular text directly before the inserted field. For example, typing "INV-" right before the field code will display "INV-1", "INV-2", and so on when updated.
Do I absolutely need to use VBA to auto-rename the file?
Yes. By default, word processors do not feature a native rule to pull text from a document field and apply it automatically to the 'Save As' dialogue. A VBA macro is required to extract that specific text and trigger the save operation.




