Exploring Tables-of-Contents in Open XML WordprocessingML Documents (Part 2)
Return to the WordprocessingML Screen-Cast SeriesMany Open XML developers need to generate documents, and then generate and insert an updated table-of-contents for the document. TOC's in Open XML are not hard, but they require a bit of explanation. This post introduces the second in a series of screen-casts around Open XML WordprocessingML TOCs.
In the first screen-cast, I explored the markup for a TOC, discussed the <w:updateFields> element in the settings part, and showed Word's behavior when that field is set.
In this second screen-cast, I discuss a bit more about the markup, and then walk through some example code that is part of the PowerTools for Open XML project. The example code shows how to insert a TOC at a desired point in a document, and then set the <w:updateFields> element. Then, when the user next opens that document, Word will present them with the option to repaginate and update the TOC.
As part of the definition of each TOC, you specify a set of switches that Word uses as instructions on how to construct the TOC. This screen-cast discusses the TOC switches, and shows how to find out more about them from the text of the Open XML standard.