View Single Post
 
Old 05-04-2019, 12:53 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
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

Try combining the following macro with a change in your TOC field, from:
"Heading 2,2,Heading 3,3,ATA MEL Item,5"
to:
"Heading 2,2,Heading 3,3" \f
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim Tbl As Table, r As Long, Rng As Range, StrTC As String
For Each Tbl In ActiveDocument.Tables
  With Tbl
    If Split(.Cell(1, 1).Range.Text, vbCr)(0) = "ATA - SYSTEM &" Then
      For r = 5 To .Rows.Count
        StrTC = "TC " & Chr(34) & Split(.Cell(r, 1).Range.Text, vbCr)(0)
        Set Rng = .Cell(r, 2).Range
        With Rng
          .End = .End - 1
          StrTC = StrTC & " " & .Text & Chr(34) & " \l 5"
          .Collapse wdCollapseEnd
          .Fields.Add .Duplicate, wdFieldEmpty, StrTC, False
        End With
      Next
    End If
  End With
Next
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote