Find and Index
Hello,
I am trying to find a word in a table, move to the next cell, and index that cell. Basically, I have a table field in a form filled out by users titled "Index:". They add words from their narrative that they want included in their index. These forms are then combined into one document which needs an index. This is why I need to run a command that searches for the word "Index:" and indexes the next cell.
I am still in the early learning phases of VBA and am having trouble getting the following code to work:
With ActiveDocument.Content.Find
.Text = "Index:"
.Forward = True
.Wrap = wdFindStop
Selection.MoveRight Unit:=wdCell
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
If Len(Selection.Text) > 1 Then
ActiveDocument.Indexes.MarkEntry Range:=Selection.Range, _
EntryAutoText:=SelectedText, CrossReference:="", CrossReferenceAutoText:="", _
BookmarkName:="", Bold:=False, Italic:=False
End If
End With
The code takes the cursors current location, moves over one cell, and indexes the contents. Now I just need it to start from the text "Index:" and loop through the whole document. I have tried many variations... obviously all have failed! Help!!
Brock
|