Thread: [Solved] Find and Execute
View Single Post
 
Old 10-22-2011, 11:36 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

Hi cksm4,

Try something along the lines of:
Code:
Sub Demo()
Dim tRng As Range
With Selection
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "TOC"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
  End With
  While .Find.Execute
    With .Range
      If .Information(wdWithInTable) = True Then
        Set tRng = .Tables(1).Cell(.Cells(1).RowIndex + 1, .Cells(1).ColumnIndex).Range
        tRng.End = tRng.End - 1
        ActiveDocument.Indexes.MarkEntry Range:=tRng, EntryAutoText:=.Text, _
          CrossReference:="", CrossReferenceAutoText:="", BookmarkName:="", Bold:=False, Italic:=False
      End If
    End With
  Wend
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote