Reputation: 131
I want to update all fields of the Microsoft Word document. Currently i am using method Microsoft.Office.Interop.Word.Document.Fields.Update() but it is not updating fields. But if I do the same thing manually by selecting total document content and press window key f9 to update fields then fields of the Microsoft Word Document are updating properly.
So Can some one suggest me is there any other way to update the Fields of word document?
Upvotes: 1
Views: 4255
Reputation: 1
When you add a new paragraph, be sure you add it at the end of the previous paragraph, then your fields will update. Do NOT add the new paragraph at the beginning of the current paragraph. See example:
2.00 Paragraph End (Press "Enter" here for a new Paragraph 2.01) 2.01 (Do NOT press "Enter" here) Beginning of Paragraph
Upvotes: 0
Reputation: 471
For the specific case of updating the tables of contents/figures:
// Microsoft.Office.Interop.Word.Document document;
foreach (TableOfContents tableOfContents in document.TablesOfContents)
{
tableOfContents.Update();
}
foreach (TableOfFigures tableOfFigures in document.TablesOfFigures)
{
tableOfFigures.Update();
}
foreach (Range storyRange in document.StoryRanges)
{
storyRange.Fields.Update();
}
I hope this covers the fields you need to update, or gives you enough information to extrapolate to your fields.
Upvotes: 1