Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 07-12-2020, 05:13 PM
Guessed's Avatar
Guessed Guessed is online now Wildcard Search Windows 10 Wildcard Search Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

It looks like the Covid-19 lockdown is getting to you Greg. I thought it was a strange coincidence when the other thread appeared after yours.

Ignoring the compound words complication, the code could be as below. I think you could even add a \- into the search strings to include the compound words.
Code:
Sub ScratchMacro2()
Dim oRng As Range
  Set oRng = ActiveDocument.Range
  oRng.HighlightColorIndex = wdAuto
  oRng.Text = "Mary has an ax, a mule and an apple." & vbCr & "Tom conducted a low-grade in-depth on-site inspection."
  With oRng.Find
    .Text = "<[AEIOUaeiou]*>"   'starts with a vowel
    .MatchWildcards = True
    .Wrap = wdFindStop
    Do While .Execute
      Select Case lcase(Right(Trim(oRng), 1))
        Case "a", "e", "i", "o", "u" 'also ends with a vowel
          oRng.HighlightColorIndex = wdBlue
        Case Else     'starts but doesn't end with a vowel
          oRng.HighlightColorIndex = wdYellow
      End Select
      oRng.Collapse wdCollapseEnd
    Loop
  End With
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .Text = "<[A-z]@[AEIOUaeiou]>"    'Find words starting with a vowel
    .MatchWildcards = True
    .Highlight = False            'and not already highlighted
    While .Execute
      oRng.Select
      oRng.HighlightColorIndex = wdBrightGreen
      oRng.Collapse wdCollapseEnd
    Wend
  End With
lbl_Exit:
  Exit Sub
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
 

Thread Tools
Display Modes


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 01:20 AM.


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