How to search for words in all caps

  • Thread starter christophercbrewster via OfficeKB.com
  • Start date
C

christophercbrewster via OfficeKB.com

I need a macro to find all the acronyms used in a document, but can't think
of an efficient way to find them. The all-caps attribute for fonts doesn't
find it, because that's a way of displaying text that is NOT actually all-cap.
The brute-force approach would be kind of painful-- if the first character is
one of the characters in this list (of capital letters), go to the second
letter, and if THAT one is in the list, go to the third letter..., and do
this for every word in the document. Is there a function that can make this
more efficient?

--
Christopher Brewster
Lockheed Martin, Eagan MN

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/201004/1
 
D

Doug Robbins - Word MVP

Use <[A-Z]{2,}> in a wildcard search. That will find any word that consist
solely of 2 or more capital letters.


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
C

christophercbrewster via OfficeKB.com

That's good-- I even use wildcard searches and didn't think of it. I did the
following, but it's slow. It just looks at the first two letters (so it
missed two acronyms, A2RF and DoD). I have another macro, OmitRedundantRows,
that boils this down to a usable list.

sList = ""
For Each sWord In Selection.Document.Words
sC = sWord.Characters(1)
If sC = "E" Or sC = "T" Or sC = "A" Or sC = "O" Or ... (I'll spare
you the rest) Then
If sWord.Characters.Count > 1 Then
sC = sWord.Characters(2)
If sC = "E" Or sC = "T" Or sC = "A" Or sC = "O" Or sC = "N"
Or sC = "R" ... Then
sList = sList + Chr(13) + sWord
End If
End If
End If
Next sWord

I need a macro to find all the acronyms used in a document, but can't
think
[quoted text clipped - 8 lines]
this
more efficient?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top