As described in the endless labyrinth of Microsoft documentation , you can block the field code. For example, in VBA, if I have one date field in the body in the form
{DATE \@ "M/d/yyyy h:mm:ss am/pm" \* MERGEFORMAT }
I can run
ActiveDocument.Fields(1).Locked = True
Then, if I made changes to the document, save and then open it again, the field code will not be updated.
An example of using C # Office Interop:
Word.Application wordApp = new Word.Application(); Word.Document wordDoc = wordApp.ActiveDocument; wordDoc.Fields.Locked = 1;
You can put the code in the DocumentOpen event. I assume you have an add-in that subscribes to this event. If not, please clarify, as this may be a battle in itself.
EDIT: In my testing, lock fields in this way block them in all StoryRanges , so there is no need to get field instances in headers, footers, footnotes, text boxes, etc. This is an amazing pleasure.
Johnzaj
source share