Document Editing Problems

How to Create Sequential Invoice Numbers and Auto-Rename Word Files

Bushra ParveenBushra Parveen Oct 20, 2026 872 views

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.

How to Create Sequential Invoice Numbers and Automatically Rename Word Files
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.
Before you start

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).

Solution 1Recommended

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.

1
Insert blank field brackets

Press Ctrl + F9 on your keyboard to insert a set of blank field brackets { }.

2
Enter the sequence code

Inside the brackets, type the code: SEQ InvoiceNumber \r 1 to set the starting sequence number to 1.

3
Update the field

Press F9 while your cursor is inside the field to update it and display the starting number.

4
Refresh all fields

To update all fields in the document simultaneously (e.g., for the next invoice), press Ctrl + A to select all text, then press F9.

Use Field Codes to Set a Sequential Invoice Number
Referencing the Number in Headers: To display the same invoice number in a header or footer, create a bookmark for your SEQ field and reference it using a cross-reference or a DocProperty field.

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. 1. Create an invoice layout: Open WPS Writer, start a new document, and design your invoice layout or open an existing template.
  2. 2. Insert the field code: Press Ctrl + F9 to generate field brackets and type your sequence logic, such as SEQ Invoice \r 1.
  3. 3. Update the invoice number: Right-click the field code and select 'Update Field' or simply press F9 to display the generated number.
  4. 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.
Fully compatible with Microsoft Word .docx and .docm formatsRobust support for advanced field codes, including SEQ and DocPropertyClean, tabbed interface to easily manage multiple open invoices at onceLightweight and fast execution, even with complex document layouts
microsoft office alternative - wps office

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.