In the first screen-cast in this series, I examined the markup for tables-of-contents in WordprocessingML documents. In the second screen-cast, I presented a bit of code that showed how to insert a non-updated TOC into a document, and to set the <w:updateFields> element in the settings part to true. Setting that element to true causes Word to ask whether to update fields when the user opens the document, and if the user responds with 'yes', then the document is repaginated, and the TOC is updated. However, having the user be presented with that modal dialog box may not be the experience you want, so in this screen-cast, I show how you can use Word Automation to open and save the document, thereby causing all fields to be updated, including the TOC.
I've attached the code to this post.
Here is the complete list of screen-casts in this series.
Explains the markup of tables-of-contents. TOCs use field markup.See Deep dive into OpenXML Fields for more info.
Presents some sample code that shows how to insert TOC markup into a document.
Shows how to use Word Automation to update the TOC.
Shows how to use Word Automation Services to update the TOC.
Shows how to use an AutoOpen macro to update the TOC whenever any document that contains a TOC is opened.