eshurak
asked on
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.
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
If Not Intersect(SearchRange, ExcludeField) Is Nothing Then
ASKER
Thanks, but Intersect is only in Excel and I'm using Word. Is there a Word equivalent?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.