Thread: [Solved] Delete a Line in a TOC
View Single Post
 
Old 11-25-2024, 07:46 AM
KoolBreeze KoolBreeze is offline Windows 11 Office 2021
Novice
 
Join Date: Nov 2024
Posts: 8
KoolBreeze is on a distinguished road
Default

It’s fine if they reappear when the TOC is updated. This document is a bit unusual and will have very circulation/updates. It has multiple TOCs, a main heading style that is level 1, and multiple subheading styles that are level 2. Each of the subheading styles are unique to a single TOC. Each of the TOCs are setup to pick up the level 1 headings (which are throughout the document) and their unique subheadings. That part works fine. The trouble is there isn’t always a subheading of each unique style after each level 1 heading, and I only want them to appear in the TOCs when there is. In other words, I don't want the level 1 heading in the TOCs unless a subheading appears after it.



I’ve been manually deleting the entries without subheadings, but I was hoping to automate it someway. I’ve tried looping through the paragraphs and using the Paragraph.Range.Delete method to delete them but I’ve not been able to get that to work reliably. I can change the background and/or font color but can't delete them.



I also thought about using the “if” statement in the TOC field codes to check for the subheading before including the level 1 heading, but I’m not sure if that’s possible. That would be a great solution if it would work.
Reply With Quote