Thanks for that Doug. It worked a treat.
I am trying to do other things with this. I have managed to operate the
code
from a userform and have managed to give the option of the CAPITAL words
being arranged in vertical or horizontal format.
Would you be so kind as to give me tip on how to be able to count the
unique
occurences of each word? Also i want to be able to programatically
delete all
duplicates of a word.
For some reason my Answer Wizard section of the VBA help is blank so
finding
a few hints is proving extremely difficult
Many thanks
:
The following should do what you want:
Dim Source As Document, Target As Document, Capword As Range
Set Source = ActiveDocument
Set Target = Documents.Add
Source.Activate
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="[A-Z]{2,}[ .]{1}",
MatchWildcards:=True,
Wrap:=wdFindStop, Forward:=True) = True
Set Capword = Selection.Range
If Right(Capword, 1) = "." Then
Capword.End = Capword.End - 1
End If
Target.Range.InsertAfter Capword.Text & vbCr
Loop
End With
Target.Activate
Target.Content.Sort SortOrder:=wdSortOrderAscending
--
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
Thanks Jay,
Yes, copy them them to a new word. The ultimate intention is to
arrange
these words in alphabetical order.
regards
:
On Sun, 31 Jul 2005 16:27:02 -0700, "Gem_man"
Plesae could someone help me out with some code to extract words
that
appear
in CAPITAL LETTERS in a word document?
I cannot find any reference to this in VBA help files.
Many thanks
The general approach is to use a wildcard search (see
http://www.gmayor.com/replace_using_wildcards.htm) and search for
the
expression
<[A-Z]@>
That will find each word that consists of only upper case letters.
What you do with the word once you find it depends on what you mean
by
"extract". Do you want to copy them to another document?