Hi,
I want to restrict a find/replace action to an index.
In my .doc i have 3 indexes each one being with a particuliar switch
\f "a" \f b" and \f "c".
I want to go to the one with \f "b".
Thanks in anticipation,
Jean-Paul
Hi Jean-Paul,
Try this:
Sub SelectIndexB()
Dim oRg As Range
Dim qt As String
qt = Chr$(34)
Set oRg = ActiveDocument.Range
oRg.TextRetrievalMode.IncludeFieldCodes = True
With oRg.Find
.Text = "^d index"
.Format = False
.Forward = True
.Wrap = wdFindStop
Do While .Execute
If InStr(LCase(oRg.Fields(1).Code.Text), _
"\f " & qt & "b" & qt) Then
oRg.Select
Exit Do
End If
Loop
End With
End Sub
The IncludeFieldCodes setting means the field code doesn't have to be
displayed on the screen in order to be found by the search. The search
finds each Index field (by looking for "^d index", where ^d is the
code for a field brace), and examines the field's code to see if there
is a \f "b" switch in it. If it's there, the macro selects the field
and jumps out of the search loop.
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.