list of all words meeting a woldcard criteria

A

adgorn

I have numerous different key words in a document that I have identified with
a caret (^) at the beginning and end. How can I search on ^*^ and get list
of all those various words? Thanks.
 
D

Dave Lett

Hi Alan,

You can use something like the following:

Dim sKeyWord As String
Dim oDoc As Document

With Selection
.HomeKey Unit:=wdStory
With .Find
.Text = "^^*^^"
.ClearFormatting
.MatchWildcards = True
Do While .Execute
sKeyWord = sKeyWord & _
Replace(Selection.Text, "^", "") & _
vbCrLf
Loop
End With
End With

Set oDoc = Documents.Add
oDoc.Range.InsertAfter Text:=sKeyWord

HTH,
Dave
 
A

adgorn

Thank you very much, worked great!
--
Alan


Dave Lett said:
Hi Alan,

You can use something like the following:

Dim sKeyWord As String
Dim oDoc As Document

With Selection
.HomeKey Unit:=wdStory
With .Find
.Text = "^^*^^"
.ClearFormatting
.MatchWildcards = True
Do While .Execute
sKeyWord = sKeyWord & _
Replace(Selection.Text, "^", "") & _
vbCrLf
Loop
End With
End With

Set oDoc = Documents.Add
oDoc.Range.InsertAfter Text:=sKeyWord

HTH,
Dave
 
A

adgorn

This macro has been working well. One thing I noticed though is that it
ignores case sensitivity. I have a number of words that are the same except
for case. Would it be possible for it to consider words where case is
different and return unique entries if the same spelling contains different
cases w/i the word?
 
D

Dave Lett

Hi Alan,

My environment doesn't experience a problem with case sensitivity. That is,
the routine should get all the words between "^" and "^" regardless of the
case or anything else.

HTH,
Dave
 
R

Russ

Alan,
If you are asking for Dave's routine to be case sensitive, then add ...
..MatchCase = True
....as one of the search requirements under the .MatchWildcards = True in
Dave's routine.
Otherwise, would you give an example of what you mean?
 

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