idemntifying the words in a list

D

Designingsally

I have a list. It has 3 or more points. I want the macros to identify the
words- benz, tv, dress in that list. I wan the macros just TO HIGHLIGHT THAT
WORD ALONE, not the whole sentence.
Give a comment saying good.
For example:

I got a :

* brand new mercedes benz
* brand new tv
* lovely dress


I want the word BENZ to be highlighted alone
I want the word TV alone to be highlighted
I want the word dress alone to be hihglighted

I believe in Hope.

DesigningSally
 
P

Pesach Shelnitz

Hi Sally,

The following macro looks for each word included in the array in all
bulleted items,
highlights the word found, and adds a comment to the selection.

Sub AddCommentInBullet()
Dim textArray As Variant
Dim i As Long
Dim j As Long

textArray = Array("benz", "tv", "dress")
With ActiveDocument
For i = 1 To .ListParagraphs.Count
With .ListParagraphs(i).Range
If .ListFormat.ListType _
= wdListBullet Then
For j = 0 To UBound(textArray)
If .Find.Execute(findText:=textArray(j), _
Forward:=True) Then
.Select
ActiveDocument.Comments.Add _
Range:=Selection.Range, Text:="Good"
End If
Next
End If
End With
Next
End With
End Sub
 

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