View Single Post
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey[_2_] Greg Maxey[_2_] is offline
external usenet poster
 
Posts: 668
Default Find and highlight all instances of ALL CAPS

USay,

AFAIK there isn't a complete solution. You can certainly find and highlight
all instances ALL CAP words. With a macro, you can even exclude the
specific acronyms FBI and CIA, however excluding "like" acronyms is a
different matter:

Sub SratchMacro()
Dim oRng As Range
Set oRng = ActiveDocument.Content
With oRng.Find
.ClearFormatting
.Text = "[A-Z]{2,}"
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
Do While .Execute
With oRng
Select Case .Text
Case "FBI", "CIA" 'add as many acronyms as necessary.
'Do Nothing
Case Else
.HighlightColorIndex = wdYellow
End Select
End With
Loop
End With
End Sub

For help installing macros see:

http://www.gmayor.com/installing_macro.htm

Note the macro above only searches the current document story range (range
containing the cursor). If you need to search all story ranges (e.g.,
headers, footers, etc.) then it would require more code.



ISay wrote:
I know, thanks to y'all, that [A-Z]{2,} will find words written in
ALL CAPS. How can I find and highlight all instances?

Is there a way to get it to recognize whole words and not instances
like FBI or CIA?

When I have searched for words and then marked them to be
highlighted, when I exit the FIND window, the highlighting
disappears. I know I'm not doing something right but I don't know
what.


--
Greg Maxey

See my web site http://gregmaxey.mvps.org
for an eclectic collection of Word Tips.

Arrogance is a weed that grows mostly on a dunghill (Arabic proverb)