Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #8  
Old 11-25-2024, 06:11 PM
Guessed's Avatar
Guessed Guessed is offline Delete a Line in a TOC Windows 10 Delete a Line in a TOC Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,185
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Paul, I think you are not understanding what the OP is trying to do. My interpretation of what they are saying could be addressed by this macro.

This refreshes the TOC and then steps backwards through the entries and removes any TOC1s that are followed immediately by another TOC1 (doesn't have a child)

Code:
Sub TOC_Fiddler()
  Dim aPar As Paragraph, aTOC As TableOfContents, i As Integer, aRng As Range
  Set aTOC = ActiveDocument.TablesOfContents(1)
  aTOC.Update
  Set aRng = aTOC.Range
  For i = aRng.Paragraphs.Count - 1 To 1 Step -1
    If aRng.Paragraphs(i).Style = "TOC 1" And aRng.Paragraphs(i).Next.Style = "TOC 1" Then aRng.Paragraphs(i).Range.Delete
  Next i
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
 



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 01:38 PM.


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