问题
Hello,
I am using the Microsoft.Office.Interop.Word library to automatically fill text into a Word template form (.dotx).
When i am filling the form with text i use MS Word bookmarks like this:
object oBookMark = "Bookmark-To-Find";
doc.FormFields.get_Item(ref oBookMark).Result = Value-To-Insert;
This works without any problems, the problem is when i add a MS Word reference to the bookmark.
The reference is there so i don't need to fill out same information 100 times in the same document.
The MS Word Reference needs to be manually updated when the document is created. Is there anyway to fix this?
Questions: Can i update all references with c# code? Is there any better way to make this?
回答1:
You need to update all fields in the document:
doc.Fields.Update();
You can also update particular fields only by calling the Update() method of the respective fields within the doc.Fields
collection.
来源:https://stackoverflow.com/questions/14299292/update-word-ref-microsoft-office-interop-word