Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-11-2020, 11:22 AM
gmaxey gmaxey is offline Wildcard Search Windows 10 Wildcard Search Office 2016
Expert
Wildcard Search
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,440
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default 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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Wildcard Search Want to do single wildcard search for Z?Z or Z??Z MikeForward Word 9 02-19-2019 01:27 AM
Wildcard Search 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
Wildcard Search Tricky wildcard search NobodysPerfect Word 10 03-19-2014 04:29 AM
Wildcard search help. Kempston Word 0 11-13-2009 03:58 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:45 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft