Exploring Tables-of-Contents in Open XML WordprocessingML Documents (Part 3)

Return to the
WordprocessingML Screen-Cast
Series

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 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.

Link

Summary

Screen-cast #1

Explains the markup of tables-of-contents. TOCs use field markup.
See Deep dive into OpenXML Fields for more info.

Screen-cast #2

Presents some sample code that shows how to insert TOC markup into a document.

Screen-cast #3

Shows how to use Word Automation to update the TOC.

Screen-cast #4

Shows how to use Word Automation Services to update the TOC.

Screen-cast #5

Shows how to use an AutoOpen macro to update the TOC whenever any document that contains a TOC is opened.

Example – Download Code