문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top