Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-03-2011, 09:10 AM
cksm4 cksm4 is offline Find and Index Windows XP Find and Index Office 2007
Advanced Beginner
Find and Index
 
Join Date: Aug 2010
Posts: 48
cksm4 is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 01-03-2011, 11:33 AM
cksm4 cksm4 is offline Find and Index Windows XP Find and Index Office 2007
Advanced Beginner
Find and Index
 
Join Date: Aug 2010
Posts: 48
cksm4 is on a distinguished road
Default

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
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and Index 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

Other Forums: Access Forums

All times are GMT -7. The time now is 11:34 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft