How to Show the Next Word SEQ Number Before Inserting a Building Block
Question details
The user wants to display the upcoming table sequence (SEQ) number within a VBA user form before inserting a building block that contains a SEQ field.

- Product
- Word
- Device & OS
- not provided
- Scenario
- Using a VBA user form to insert formatted tables or building blocks that require sequential numbering.
- Observed behavior
- A method is needed to accurately calculate and display what the next SEQ number will be before the field is actually generated inside the document.
Ensure that the Developer tab is enabled in your word processor to access the VBA Editor, and make sure your document is saved as a macro-enabled format (.docm or .dotm).
Use Document Variables to Track Sequence Numbers
Store the current sequence number in a document variable, allowing the VBA user form to retrieve and increment it easily.
This is the most reliable method, as it isolates the sequence count from document formatting changes. You must initialize a variable in your template before calling it.
In your template's initialization code, set an initial value for the sequence by adding: ActiveDocument.Variables("tblseq").Value = 0.
In the VBA Editor, add code to the UserForm's Activate event to read the document variable, add 1, and output it to your text box so the user can preview it.
Modify the code that inserts the building block to not only insert and update the SEQ field but also save the newly updated sequence number back to ActiveDocument.Variables("tblseq").Value.

Count Existing Tables in the Document
A simpler alternative to calculate the next sequence number by counting the total number of tables currently in the document.
Retrieve Field Value from the Last Table
Extract the actual SEQ field value from the most recently inserted table in the document and increment it.
Automate Documents Seamlessly with WPS Writer
WPS Writer provides comprehensive support for document automation, field codes, and macros, making it incredibly easy to manage sequence numbers and custom building blocks.
- 1. Insert SEQ fields manually: Open WPS Writer, navigate to the 'Insert' tab, click 'Field', and select 'Seq' to configure sequential numbering manually.
- 2. Save custom building blocks: Create your table containing the SEQ field, highlight it, and save it to your Quick Parts for fast access.
- 3. Enable the Developer tab: Go to settings to enable the Developer tab, giving you full access to the Macro editor for custom VBA user forms.
- 4. Run your scripts: Execute your form scripts to seamlessly preview sequence numbers and insert automated tables within your WPS document.

Frequently Asked Questions
What is a SEQ field in Word processing software?
A SEQ (Sequence) field is a code used to sequentially number items in a document, such as tables, figures, or custom lists. It updates automatically as new items are inserted or rearranged.
How do I initialize a document variable using VBA?
You can initialize a document variable by running a simple macro containing the command ActiveDocument.Variables("YourVariableName").Value = 0 before triggering your user form.
Can I store a table with a SEQ field in Quick Tables?
Yes, you can format a table, insert the desired SEQ field inside it, select the entire table, and save it to Quick Tables or Quick Parts. This allows your VBA code to insert the pre-configured block quickly.
Why is my SEQ field not updating automatically?
SEQ fields sometimes require a manual refresh. You can select the document text (Ctrl + A) and press F9 to force all fields, including SEQ fields, to update to their correct sequential numbers.




