Convert table of contents (TOC) to normal text
-
14-07-2021 - |
Domanda
In MS Word, table of contents (TOC) can be converted to normal text manually using Ctrl-Shift-F9.
Is there a way to convert TOC to normal text programatically?
Word VBA has TableOfContents class but, it seems, the class doesn't provide any method that can be used for such conversion.
Soluzione
Well, it is not that hard. Here is the solution:
For Each nextTOC In ActiveDocument.TablesOfContents
nextTOC.Range.Fields.Unlink
Next
In the snippet above, the code loops through all the tables of contents in the active document, gets Fields property of each TOC's Range and calls Unlink on it.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow