Reputation: 58
What pattern can I use in MS Word's advanced find to highlight phrases where every word starts with a capital letter? The phrases have a varying number of words, and the words a varying number of letters. If there is a full stop, or a word that starts with a lowercase letter, then that is the end of a phrase
Example of phrases to highlight
For the purposes of the Legal Contract he will email the Signed AAA Document. The Signed Reviewed Document will then be archived.
Upvotes: 0
Views: 383
Reputation: 13505
Try:
Sub Demo()
Application.ScreenUpdating = False
Dim i As Long
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "<[A-Z][A-Za-z]@ [A-Z][A-Za-z]@>"
.Replacement.Text = ""
.Forward = True
.Format = False
.Wrap = wdFindStop
.MatchWildcards = True
.Execute
End With
Do While .Find.Found
i = i + 1
Do While .Words.Last.Next Like "[A-Z]"
.MoveEnd wdWord, 1
Loop
.HighlightColorIndex = wdYellow
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
Application.ScreenUpdating = True
MsgBox i & " strings processed."
End Sub
For PC macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm
For Mac macro installation & usage instructions, see: https://wordmvp.com/Mac/InstallMacro.html
Upvotes: 2