Many Open XML developers need to generate documents, and then generate and insert an updated table-of-content for the document. TOC's in Open XML are not hard, but they require a bit of explanation. This blog post introduces the first of several screen-casts around Open XML WordprocessingML TOCs.
Return to the Table of Contents of the screen-cast series on WordprocessingML.
This first video looks at how TOC's can (but are not required to) be in a content control. It shows how WordprocessingML uses field markup to represent a TOC. It walks through the field markup, explaining the markup, and explaining how fields can be nested. It shows how you can remove the automatically generated contents of a TOC, and by setting the <w:updateFields w:val='true'/> element in the settings part, you can cause Word to refresh the TOC the next time that the document is opened.
Links referenced in this video:
Open XML Package Editor Power Tool for Visual Studio 2010Open XML Markup Simplifier ApplicationDeep dive into fields in WordprocessingML
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.
-Eric
Hello Eric!
I use openxml powertools and I am confronted with a special issue. I have a Control Content field in a word document . The control contains more lines with carriage return. I changed the font to bold. When I start the mailmerge (with use of
power tools) the font changes to defualt font. When I have a control without any CR, it works. The font remains. The problem is with multiline Content Controls.
Please Help!
Best regards
Babak
Hi Babak,
Best approach is to submit this as a separate question in the forum. It would be great if you can submit sample documents and code also.
I submitted a part of my code. I think I have problems preserving the font characteristics while removing and reinserting the nodes.
Thank you!