{"id":3170,"date":"2016-03-20T05:01:13","date_gmt":"2016-03-20T05:01:13","guid":{"rendered":"http:\/\/www.ericwhite.com\/home2\/bm8qcmjy\/public_html\/blog\/?page_id=3170"},"modified":"2016-03-20T09:41:27","modified_gmt":"2016-03-20T09:41:27","slug":"exploring-tables-of-contents-in-open-xml-wordprocessingml-documents-part-3","status":"publish","type":"page","link":"https:\/\/www.ericwhite.com\/blog\/exploring-tables-of-contents-in-open-xml-wordprocessingml-documents-part-3\/","title":{"rendered":"Exploring Tables-of-Contents in Open XML WordprocessingML Documents (Part 3)"},"content":{"rendered":"<p><span class=\"Back\"><a class=\"Back\" href=\"https:\/\/www.ericwhite.com\/blog\/introduction-to-wordprocessingml-series\/\">Return to the<br \/>WordprocessingML Screen-Cast<br \/>Series<\/a><\/span><\/p>\n<p>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 &#8216;yes&#8217;, 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.<\/p>\n<p>I&#8217;ve attached the code to this post.<\/p>\n<p><iframe loading=\"lazy\" title=\"TocAdder3.wmv\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/GTVRC1wuraU?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<p>Here is the complete list of screen-casts in this series.<\/p>\n<table style=\"border-collapse:collapse;border:none;\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td style=\"border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;font-weight:bold;\" valign=\"top\">\n<p>Link<\/p>\n<\/td>\n<td style=\"border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;font-weight:bold;\" valign=\"top\">\n<p>Summary<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;\" valign=\"top\">\n<p><a href=\"https:\/\/www.ericwhite.com\/blog\/screen-cast-exploring-tables-of-contents-in-open-xml-wordprocessingml-documents\/\">Screen-cast #1<\/a><\/p>\n<\/td>\n<td style=\"border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;\" valign=\"top\">\n<p>Explains the markup of tables-of-contents. TOCs use field markup.<br \/>See <a href=\"https:\/\/www.ericwhite.com\/blog\/2011\/04\/25\/deep-dive-into-open-xml-wordprocessingml-fields-and-hyperlinks\/\">Deep dive into OpenXML Fields<\/a> for more info.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;\" valign=\"top\">\n<p><a href=\"https:\/\/www.ericwhite.com\/blog\/exploring-tables-of-contents-in-open-xml-wordprocessingml-documents-part-2\/\">Screen-cast #2<\/a><\/p>\n<\/td>\n<td style=\"border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;\" valign=\"top\">\n<p>Presents some sample code that shows how to insert TOC markup into a document.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;\" valign=\"top\">\n<p><a href=\"https:\/\/www.ericwhite.com\/blog\/exploring-tables-of-contents-in-open-xml-wordprocessingml-documents-part-3\/\">Screen-cast #3<\/a><\/p>\n<\/td>\n<td style=\"border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;\" valign=\"top\">\n<p>Shows how to use Word Automation to update the TOC.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;\" valign=\"top\">\n<p><a href=\"https:\/\/www.ericwhite.com\/blog\/exploring-tables-of-contents-in-openxml-wordprocessingml-documents-part-4\/\">Screen-cast #4<\/a><\/p>\n<\/td>\n<td style=\"border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;\" valign=\"top\">\n<p>Shows how to use Word Automation Services to update the TOC.<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;\" valign=\"top\">\n<p><a href=\"https:\/\/www.ericwhite.com\/blog\/updating-the-toc-in-a-wordprocessingml-document-using-an-autoopen-macro\/\">Screen-cast #5<\/a><\/p>\n<\/td>\n<td style=\"border:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;\" valign=\"top\">\n<p>Shows how to use an AutoOpen macro to update the TOC whenever any document that contains a TOC is opened.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Example &#8211; <a href=\"https:\/\/www.ericwhite.com\/blog\/wp-content\/uploads\/2016\/03\/TocAdder-1.zip\">Download Code<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Return to theWordprocessingML Screen-CastSeries 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 [&hellip;]<\/p>\n","protected":false},"author":10567,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"_s2mail":"","footnotes":""},"class_list":["post-3170","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/pages\/3170","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/users\/10567"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/comments?post=3170"}],"version-history":[{"count":3,"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/pages\/3170\/revisions"}],"predecessor-version":[{"id":3178,"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/pages\/3170\/revisions\/3178"}],"wp:attachment":[{"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/media?parent=3170"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}