Thank you for the help. I will play around with the IF statement but each TOC does have 2 levels. Here are couple of the field codes from 2 of them.
{ TOC \O "1-1" \H \Z \T "ITEM HEADING - FIRSTLIST,2" \W }
{ TOC \O "1-1" \H \Z \T "ITEM HEADING - SECONDLIST,2" \W }
There are 7 TOCs in the document total, with the only difference in the field codes being the name of the subheadings, e.g. "ITEM HEADING - FIRSTLIST". The challenging part is that the subheadings are throughout the document under various level 1 headings. Some level 1 headings only have 1 of the subheadings under it while others may have them all. Each TOC needs include only the level 1 heading and any of its subheadings, except that if there are no subheadings of a specific style under the level 1 heading then that TOC should also exclude the level 1 heading. I know, highly unusual. It's not necessary for the hyperlinks to work.
What I was attempting to do in VBA was update the TOCs, which adds all of the level 1 headings, as well as all of each TOCs subheadings, then loop back through the TOC paragraphs and remove the unwanted level 1 headings. I could can the formatting of them but have not been able to figure out how to remove them reliably. I'm not that familiar with using VBA in Word though.
|