Thread: [Solved] Delete a table of contents
View Single Post
 
Old 12-17-2025, 07:33 AM
TheBigBoss TheBigBoss is offline Windows 10 Office 2016
Advanced Beginner
 
Join Date: Dec 2016
Posts: 58
TheBigBoss is on a distinguished road
Default Delete a table of contents

Hi there,

Having a small issue, I want to delete all TOCs found in ActiveDocument but whatever I do, the TOC container remains.

This will delete the heading of the TOC, if any... and delete all content in range (mostly TOC fields)
Code:
For Each toc In ActiveDocument.TablesOfContents
        toc.Range.Previous(Unit:=wdParagraph).Delete
        toc.Range.Delete
    Next toc
What is the property of the TOC container, it is not a Content Control as this returns nothing
Code:
For Each cc In ActiveDocument.ContentControls
        MsgBox cc.Type
Next cc
Thanks for your help
Reply With Quote