Frage

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.

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top