A family of Microsoft word processing software products for creating web, email, and print documents.
The message “Error! No document variable supplied.” indicates that Word is evaluating a DOCVARIABLE field without a valid document variable; replace it with a MERGEFIELD linked to your mail-merge data source if the content is intended to come from that source.
Check and correct the field
- Open the document in Word for Windows desktop.
- Press Alt+F9 to display field codes.
- Examine the affected field.
If it resembles:
{ DOCVARIABLE }
or:
{ DOCVARIABLE "Your field name" }
it is a document-variable field, not a mail-merge field. A valid DOCVARIABLE field has the syntax { DOCVARIABLE "Name" } and displays a variable stored inside the document. If that variable has not been supplied, the field cannot produce a result.^1^
For mail merge, the field should instead resemble:
{ MERGEFIELD "Your 38-character field name" }
The name must exactly match the column heading in the connected data source.^2^
- Delete the incorrect field.
- Go to Mailings → Select Recipients and connect the correct Excel, CSV, or other mailing list. Word requires the data source to be selected before inserting merge fields.
- Place the cursor where the value belongs, then choose Mailings → Insert Merge Field and select the field from the list. Do not type the braces manually.
- Select Mailings → Preview Results and move between records to verify that the source value appears.
- Press Alt+F9 again if field codes remain visible.
About the 38-character name
The official Word documentation supplied here does not specify a general maximum length for native MERGEFIELD names. The documented requirement is that the field name exactly match the header in the selected data source.^2^
A separate 40-character field-name limit appears in guidance for the third-party Merge Tools Add-in, but that is an add-in requirement and should not be treated as Word’s general mail-merge limit.^3^ In any event, a 38-character name is below that add-in-specific limit.
If Alt+F9 already shows a correctly formed MERGEFIELD, compare its name—including spaces—with the data-source column heading, then delete and reinsert it through Mailings → Insert Merge Field. Word supports updating a selected field with F9, but reinserting it avoids retaining the wrong field type or an outdated header name.^4^
If the field genuinely is intended to be a DOCVARIABLE, the document or its VBA automation must create and populate that named variable before the field is updated. Document variables are stored in the document and are distinct from mail-merge columns.^5^
References