Hey Paul,
Thanks again for replying. I worked on this last night and made a little progress. As you can see below I set the selected text to a variable:
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Level 1"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCell
vCatagory1 = Selection.Text
Selection.Collapse
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Level 2"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCell
vCatagory2 = Selection.Text
Selection.Collapse
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Level 3"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCell
vCatagory3 = Selection.Text
Selection.GoTo What:=wdGoToBookmark, Name:="IndexThis"
ActiveDocument.Indexes.MarkEntry Range:=Selection.Range, _
Entry:=vCatagory1 & ":" & vCatagory2 & ":" & vCatagory3, CrossReference:="", CrossReferenceAutoText:="", _
BookmarkName:="", Bold:=False, Italic:=False
This creates a three level index based on the values of the three fields. It works but I am back to the loop issue as this code needs to run for each document. My final document is a combination of mutiple forms (page breaks between) filled out by the user. I can run this code on each form as it is created, but I prefer to run it just once after the final combination is complete. I am struggling with the transition from the first search to the "Do While" and have not been able to get it to work.
Brock
|