Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-25-2024, 01:29 PM
macropod's Avatar
macropod macropod is offline Delete a Line in a TOC Windows 10 Delete a Line in a TOC Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Assuming each Section has only one Level 1 Heading, then to do something like that for your various Section TOCs, you could use a field code like:



{IF{TOC \o "2"}= "Error!*" "" {TOC}}

Doing this will render the TOC references unlinkable (i.e. you can't click on them and be taken to the headings). You will, of course, need to supplement both of the TOC fields in the field coding above with your existing TOC field switches for determining the bookmarked range the TOC applies to.

Note: The field brace pairs (i.e. '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac or, if you’re using a laptop, you might need to use Ctrl-Fn-F9); you can't simply type them or copy & paste them from this message. Nor is it practical to add them via any of the standard Word dialogues. The spaces represented in the field constructions are all required.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 11-25-2024, 03:06 PM
KoolBreeze KoolBreeze is offline Delete a Line in a TOC Windows 11 Delete a Line in a TOC Office 2021
Novice
Delete a Line in a TOC
 
Join Date: Nov 2024
Posts: 8
KoolBreeze is on a distinguished road
Default

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.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete a Line in a TOC Horizontal line I can't delete goingvirtual Word 2 09-09-2018 02:58 AM
Delete a Line in a TOC Delete certain characters from a line Helend269 Word VBA 5 01-09-2018 12:08 PM
Delete a Line in a TOC Delete line above sidenote JackDaniels Word 2 10-01-2016 08:04 AM
If Statement in vba to Delete a Line mbesspiata Excel Programming 4 04-08-2014 04:32 AM
Cannot delete line adkr Office 1 04-07-2010 09:26 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:46 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft