Thread: [Solved] Find and Execute
View Single Post
 
Old 10-14-2011, 11:14 AM
cksm4 cksm4 is offline Windows XP Office 2007
Advanced Beginner
 
Join Date: Aug 2010
Posts: 48
cksm4 is on a distinguished road
Default Find and Execute

Hello,

I am trying to find text in a table and then execute a command which involves focusing on a new selection/range. I know the change is my issue but I do not know how to overcome it. Any ideas??

Code:
 
With ActiveDocument
Selection.Find.ClearFormatting
With Selection.Find
   .Text = "TOC"
   .Replacement.Text = ""
   .Forward = True
   .Wrap = wdFindContinue
   .Format = False
   .MatchCase = False
   .MatchWholeWord = False
   .MatchWildcards = False
   .MatchSoundsLike = False
   .MatchAllWordForms = False
End With
While .Execute
    .MoveDown Unit:=wdLine, Count:=1
    .SelectCell
    ActiveDocument.Indexes.MarkEntry Range:=Selection.Range, _
        EntryAutoText:=SelectedText, CrossReference:="", CrossReferenceAutoText:="", _
        BookmarkName:="", Bold:=False, Italic:=False
Wend
End With
Thanks!
Reply With Quote