![]() |
#5
|
||||
|
||||
![]()
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 |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
MikeForward | Word | 9 | 02-19-2019 01:27 AM |
![]() |
Cosmo | Word VBA | 9 | 02-12-2016 08:03 PM |
Issue with wildcard search | mysterytramp | Word | 0 | 05-13-2015 10:40 AM |
![]() |
NobodysPerfect | Word | 10 | 03-19-2014 04:29 AM |
Wildcard search help. | Kempston | Word | 0 | 11-13-2009 03:58 AM |