#1
|
|||
|
|||
Wildcard Search
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 |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Want to do single wildcard search for Z?Z or Z??Z | MikeForward | Word | 9 | 02-19-2019 01:27 AM |
Having problems with a Wildcard search | Cosmo | Word VBA | 9 | 02-12-2016 08:03 PM |
Issue with wildcard search | mysterytramp | Word | 0 | 05-13-2015 10:40 AM |
Tricky wildcard search | NobodysPerfect | Word | 10 | 03-19-2014 04:29 AM |
Wildcard search help. | Kempston | Word | 0 | 11-13-2009 03:58 AM |