#1
|
|||
|
|||
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 |
#2
|
|||
|
|||
Got it to work:
Selection.Find.ClearFormatting With Selection.Find .Text = "Index:" .Forward = True .Wrap = wdFindStop End With While Selection.Find.Execute 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 Wend |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
can Find/Replace NOT find something? | Bobosmite | Word | 6 | 05-27-2010 08:09 PM |
modifying index styles | alpruett | Word | 0 | 04-23-2010 12:52 PM |
Printing Index Cards | bOB 1927 | Word | 0 | 01-26-2010 06:51 PM |
Moving a Index/Match function | FraserKitchell | Excel | 2 | 01-19-2010 09:38 AM |
Problem with creating index | klb_08 | Word | 0 | 11-11-2009 06:08 AM |