Puzzled by behavior of "<" in a wildcard search.
Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oRng As Range
Set oRng = ActiveDocument.Range
oRng.Text = "An ax, a mule and an apple."
With oRng.Find
'This will find "only complete words" starting with a vowel.
.Text = "<[AEIOUaeiou]*>"
.MatchWildcards = True
While .Execute
oRng.Select
Wend
End With
Set oRng = ActiveDocument.Range
With oRng.Find
'So why doens't this find "only complete words" ending with a vowel.
.Text = "<*[AEIOUaeiou]>"
.MatchWildcards = True
While .Execute
oRng.Select
Wend
End With
lbl_Exit:
Exit Sub
End Sub
Here is a workaround but curious as to why the "<" seems to be ignored in second run above.
Code:
Sub KlunkyWordAround()
Dim oRng As Range
Set oRng = ActiveDocument.Range
oRng.Text = "An ax, a mule and an apple."
Set oRng = ActiveDocument.Range
With oRng.Find
'This will find "only complete words" ending with a vowel.
.Text = "[! ]@[AEIOUaeiou]>"
.MatchWildcards = True
.Wrap = wdFindStop
Do While .Execute
oRng.Select
If oRng.End = 0 Then Exit Do
Loop
End With
lbl_Exit:
Exit Sub
End Sub