Update word Ref: Microsoft.Office.Interop.Word

你说的曾经没有我的故事 提交于 2019-12-12 10:19:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!