First off, I'm using Word 2016 for Desktop.
I have a document that contains a TOC. The TOC has been copied from a different document and is broken. When I click "Update Table", I get a message box that says "There's no table of contents to update. You can insert one from the References tab."
However, I can see text of the original TOC. The TOC appears as formatted text, but it sits inside of a TOC Content Control. I can easily copy and paste that text using a cursor within Word.
However, I want to get at that text using VBA. Can I use VBA to find the text, copy it from the broken TOC Control, and paste it into a paragraph without the Control?
I have used the VBA Locals window to examine the document, but I can't figure it out. The "Count" property under TableOfContents is 0, as is the one for ContentControls.
I looked at the XML and see that the section is introduced like this:
HTML Code:
<w:sdt>
<w:sdtPr>
<w:rPr>
<w:rFonts w:ascii="Century Schoolbook" w:eastAsia="Times New Roman" w:hAnsi="Century Schoolbook" w:cs="Times New Roman"/>
<w:szCs w:val="24"/>
</w:rPr>
<w:id w:val="-1392880186"/>
<w:docPartObj>
<w:docPartGallery w:val="Table of Contents"/>
<w:docPartUnique/>
</w:docPartObj>
</w:sdtPr>
<w:sdtEndPr>
<w:rPr>
<w:b/>
<w:bCs/>
<w:noProof/>
</w:rPr>
</w:sdtEndPr>
<w:sdtContent>
...
Any one have an idea?
Thanks in advance.