Fix Word Mail Merge Not Displaying Conditional Barcodes
Question details
The user needs to display a barcode conditionally in a Word Mail Merge to avoid errors when product IDs are missing.

- Product
- Word
- Device & OS
- not provided
- Scenario
- Running a Mail Merge where some records have empty Product IDs, requiring an IF field to conditionally display a barcode.
- Observed behavior
- The IF field correctly handles regular MERGEFIELDs, but the MERGEBARCODE field fails to display the barcode when nested inside the conditional statement.
Verify that your data source is fully updated and check exactly which rows contain empty or invalid Product IDs before adjusting the field codes.
Use the DISPLAYBARCODE Field Instead of MERGEBARCODE
Replace the MERGEBARCODE field with a DISPLAYBARCODE field nested inside the IF statement to ensure the barcode evaluates and renders correctly.
When nesting fields inside an IF condition, the MERGEBARCODE field can sometimes fail to parse correctly. Using the DISPLAYBARCODE field with a nested MERGEFIELD often resolves this logic error.
Press 'Alt + F9' (or 'Option + F9' on Mac) on your keyboard to reveal the underlying field codes in your Word document.
Find the conditional IF statement that is failing to generate the barcode for valid Product IDs.
Replace the existing '{ MERGEBARCODE ProdID }' syntax with '{ DISPLAYBARCODE "{ MERGEFIELD ProdID }" QR }' (or your specific barcode type) inside the true condition of the IF field.
Press 'Alt + F9' again to hide the field codes, then click 'Preview Results' in the Mailings tab to confirm the barcode displays properly.

Pre-process the Data Source
Filter out or fix empty Product ID records in your Excel spreadsheet or database before running the mail merge.
Try WPS Office for Seamless Mail Merge and Document Creation
If you are struggling with complex field codes and errors in Microsoft Word, WPS Office provides a lightweight, highly compatible, and user-friendly alternative for all your document editing and mass mailing needs.
- 1. Download and Install: Download WPS Office for free from the official website and follow the simple installation instructions.
- 2. Open Your Document: Launch WPS Writer and open your existing .docx Mail Merge document to continue working without losing formatting.
- 3. Use Mail Merge: Navigate to the References tab and click on the Mail Merge tools to connect your data source and generate documents easily.

Frequently Asked Questions
Why does MERGEBARCODE fail inside an IF field?
The MERGEBARCODE field relies on a direct link to the data source and struggles to parse dynamically when nested inside the logical evaluation of an IF field. The DISPLAYBARCODE field is better suited for this as it evaluates the text provided by the nested MERGEFIELD instead.
How do I toggle field codes on and off in Word?
You can toggle between viewing the final result and the raw field code by pressing 'Alt + F9' on Windows or 'Option + F9' on a Mac. To toggle a single field, select it and press 'Shift + F9'.
What happens if a barcode field points to an empty cell in my data source?
If a barcode field references an empty value and is not protected by an IF statement, Word will typically display a 'Zip Code or Barcode not found' error, which can disrupt printing or saving the final merged document.
Can I generate QR codes using Word Mail Merge?
Yes, both the MERGEBARCODE and DISPLAYBARCODE fields support QR code generation. You simply need to append the 'QR' argument at the end of the field code syntax (e.g., { MERGEBARCODE ProductURL QR }).




