Fix Word VBA Clearing Legacy Form Fields When Protecting a Document
Question details
Update document-variable fields and protect a Word document without clearing legacy form field values.

- Product
- Microsoft Word VBA
- Device & OS
- not provided
- Scenario
- A Word macro updates fields and then protects a document containing legacy form fields.
- Observed behavior
- Updating the entire document field collection can erase or alter legacy form field values.
Identify the macro that calls ActiveDocument.Fields.Update and confirm which fields are DOCVARIABLE fields. If the document is already protected, use Review > Restrict Editing > Stop Protection and enter the password if prompted.
Update DOCVARIABLE Fields Individually Before Protecting the Document
Use this approach to avoid updating legacy form fields as part of a document-wide field update.
In Word, open Developer > Visual Basic and locate the macro that updates and protects the document.
Remove ActiveDocument.Fields.Update. In its place, loop through the fields and update only document-variable fields: Dim fld As Field For Each fld In ActiveDocument.Fields If fld.Type = wdFieldDocVariable Then fld.Update Next fld
After the loop, add ActiveDocument.Protect Type:=wdAllowOnlyReading to apply read-only protection. Run this statement only when the document is not already protected.
Return to Word, enter sample values in the legacy form fields, and run the macro from Developer > Macros. Check that the values remain intact and the DOCVARIABLE fields show the expected results.

Consider Content Controls for a New Word Form
Use content controls when designing a new form instead of relying on legacy form fields.
Edit Word Documents with WPS Writer
WPS Writer is a free, lightweight Office alternative with a familiar interface and support for Word formats, making it easy to move everyday document editing to WPS. It does not fix Microsoft Word VBA protection behavior.

Frequently Asked Questions
Why does Fields.Update affect my legacy form fields?
Legacy form fields are included in Word's field collection, so ActiveDocument.Fields.Update can update them along with other fields and alter their values. Update only the field types you need instead.
How do I update only DOCVARIABLE fields in Word VBA?
In Developer > Visual Basic, loop through ActiveDocument.Fields and call fld.Update only when fld.Type equals wdFieldDocVariable.
Can users fill in legacy fields under read-only protection?
Read-only protection is intended to restrict editing. If users need to fill in legacy form fields, test wdAllowOnlyFormFields instead of wdAllowOnlyReading.
Will ActiveDocument.Fields include fields in headers and footers?
The main document field collection does not cover every story range. If DOCVARIABLE fields appear in headers or footers, update those story ranges separately.




