Document Editing Problems

Fix Word Fields to Display the First and Last Barcode Numbers

Adam DavisAdam Davis Nov 22, 2026 870 views

Question details

Use Word fields to display the first and last barcode sequence numbers on a page without a formula error.

Fix Word Fields to Display the First and Last Barcode Numbers
Product
Microsoft Word
Device & OS
not provided
Scenario
A document combines SEQ, STYLEREF, and DISPLAYBARCODE fields to generate barcodes and display their sequence numbers.
Observed behavior
Applying a character style inside a barcode field can produce an Unexpected End of Formula error.
Before you start

Open the document in desktop Word and identify the sequence name and character style used for the barcode numbers. The shortcuts below are for Word on Windows; field shortcuts may differ on other systems.

Solution 1Recommended

Move Styled SEQ Fields Outside DISPLAYBARCODE

Use separate sequence fields as the STYLEREF targets and repeat their values inside the barcode fields.

Create a separate SEQ field for each barcode and apply the character style to that field, not to the field nested inside DISPLAYBARCODE. The nested SEQ field uses the \c switch to repeat the preceding value without incrementing it.

1
Create the character style

On the Home tab, open the Styles pane and create a character style named SerialField, or identify the existing character style you want STYLEREF to find.

2
Insert a separate sequence field

Before each barcode, press Ctrl+F9 to insert field braces and type SEQ Barcode between them. Apply the SerialField character style to the resulting SEQ field. Use the same sequence name for all related barcodes.

3
Repeat the value in the barcode

Place a DISPLAYBARCODE field after each separate SEQ field. Inside it, insert a nested field that repeats the preceding value, for example: { DISPLAYBARCODE { SEQ Barcode \c } CODE128 }. Use Ctrl+F9 for each pair of field braces rather than typing the braces as ordinary text.

4
Add first and last references

Open the page header or footer and insert { STYLEREF SerialField } for the first styled number and { STYLEREF SerialField \l } for the last. Insert each field using Ctrl+F9.

5
Conceal and update the fields

Select the separate SEQ field results and use Home > Font to set them to 1-point white text instead of Hidden formatting. Update the fields with F9, including the header or footer fields, and check File > Print.

Move Styled SEQ Fields Outside DISPLAYBARCODE
Check the printed result: White text may be visible on a nonwhite background and is not a security measure. If a number shows an error on screen but appears correctly in Print Preview, the on-screen result may be a Word display issue.
Free Microsoft Office alternative

Edit Word Documents with WPS Writer

WPS Office is a free, lightweight alternative with a familiar interface for opening and editing Word documents. Its format compatibility makes everyday migration easier, though it does not fix Microsoft Word field errors and complex barcode fields should be checked after opening.

Open and edit Microsoft Word DOC and DOCX filesReview document text and page layouts in a familiar interfaceUse a free, lightweight office suite for everyday document workMove common document workflows from Microsoft Office with less adjustment
microsoft office alternative - wps office

Frequently Asked Questions

Why does the barcode field show an Unexpected End of Formula error?

Applying the character style inside DISPLAYBARCODE can cause the error. Put the styled SEQ field before the barcode field and use a separate nested SEQ field with the \c switch inside DISPLAYBARCODE.

What does the SEQ \c switch do?

The \c switch repeats the closest preceding value of the named sequence instead of incrementing it. For example, use { SEQ Barcode \c } inside DISPLAYBARCODE after a separate { SEQ Barcode } field.

How does STYLEREF find the first and last numbers?

In the header or footer, insert { STYLEREF SerialField } to reference the first occurrence of the styled field on the page. Add the \l switch to reference the last occurrence: { STYLEREF SerialField \l }.

Why should I use white text instead of Hidden formatting?

The workaround uses 1-point white text for the separate styled SEQ fields rather than Hidden formatting. Set this under Home > Font, and check the result against the page background; white text is not secure or necessarily invisible.

What if the second number looks wrong on screen?

Update the fields with F9 and check File > Print. If the number appears correctly in Print Preview despite an on-screen error, the difference may be a Word display issue.