Apply the built-in Heading 1 paragraph style to all paragraphs containing text in ALL CAPS
Article contributed by Bill Coan
Sub FindAllCaps()
'start at beginning of doc
Selection.HomeKey wdStory
'get rid of any previous format criteria in the find dialog
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
'search for any paragraph that has no lowercase letters
'WARNING: If you need to exclude paragraphs with numerals,
'change the .Text argument to [!^013a-z0-9]@^013
With Selection.Find
.Text = "[!^013a-z]@^013"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Do While Selection.Find.Execute()
'change the style only if the found text
'represents the entire paragraph
If Selection.Start = Selection.Paragraphs.First.Range.Start Then
Selection.Style = wdStyleHeading1
End If
'position the cursor after the found text
'in preparation for finding the next occurrence
Selection.Collapse wdCollapseEnd
Loop
End Sub
For many more examples of wildcard searches, and for in-depth coverage of how to use wildcards, see: Finding and replacing characters using wildcards.