Using VBA how do I test if range is part of a field

Hello,

In Word 2003 I need to be able to test whether the text in a range is included in a field using VBA.

So the field is { XE "Agreement" } (this is an index marked field)

My code below is search for words that are enclosed in quotes, but I want it to exclude the ones that are part of a field.  So in the code below SearchRange will equal "Agreement".

Thanks for your help.
With SearchRange.Find

    .Text = Chr(147) & Chr(42) & Chr(148)
     .MatchWildcards = True
End With
Do While SearchRange.Find.Execute
    If SearchRange.Words.Count < 8 Then
        SearchRange.Select
        Debug.Print SearchRange & " Page - " & GetPageNumber(SearchRange) _
        & " Section - " & SearchRange.Paragraphs(1).Range.ListFormat.ListString
    End If
Loop

Open in new window

LVL 3
eshurakAsked:
Who is Participating?
 
eshurakConnect With a Mentor Author Commented:
I'm using the code below.  I should have thought of that sooner.
If ActiveDocument.Range(SearchRange.Start - 4, SearchRange.Start - 2) <> "XE" Then

Open in new window

0
 
insaneCFCCommented:
If Not Intersect(SearchRange, ExcludeField) Is Nothing Then
0
 
eshurakAuthor Commented:
Thanks, but Intersect is only in Excel and I'm using Word.  Is there a Word equivalent?
0
All Courses

From novice to tech pro — start learning today.