Identify "various" in a bullet list.

D

Designingsally

3. every bullet or any list must have a lead in sentence as per the book. So
i wnt the macros to add : at the end of the lead in sentence. If the lead in
sentences has words like "various", "as follows" then i wan the macros to
identify the sentence and give a message saying AVOID.

Example:

I have a: (this is the lead in sentence, notice the end of the lead in
sentence has a COLON. And also every lead in sentence is followed by a list)
*Book
*Pen
*paper
 
D

DaveLett

Hi,
Again, I think there are too many choices to make to make a routine like
this useful. The following routine does exactly what you've asked for.
However, if your writer has something like the following, then the routine
will insert a colon after the lead-in sentence:
I have a :

Also, the routine puts the "AVOID" comment on the whole lead-in sentence,
not just the words that you want to avoid.

Dim lList As Long
Dim oRng As Range

For lList = ActiveDocument.Lists.Count To 1 Step -1
Set oRng = ActiveDocument.Lists(lList).ListParagraphs(1).Range
With oRng
.Collapse Direction:=wdCollapseStart
.MoveStart Unit:=wdSentence, Count:=-1
.MoveEnd Unit:=wdCharacter, Count:=-1
If .Characters.Last <> ":" Then
.InsertAfter Text:=":"
End If
If InStr(1, .Text, "various") Or InStr(1, .Text, "as follows") Then
ActiveDocument.Comments.Add Range:=oRng, Text:="AVOID"
End If
End With
Next lList

HTH,
Dave
 
D

Designingsally

Dave

I want various and as follows to be highlighted in the comment box. Is that
possible?

Let me know.
 
D

DaveLett

Hi,
Yes, you can have only various or as follows highlighted. You should break
this line:
If InStr(1, .Text, "various") Or InStr(1, .Text, "as follows") Then
into two If, then structures and move the range object in each structure to
be your words. Because you're going to insert the same comment for each,
you'll need to have the line:
ActiveDocument.Comments.Add Range:=oRng, Text:="AVOID"
in both If/then. If you think you'll be using this for more than just these
two words/phrases, I'd recommend that you make this a function that receives
a string from a calling routine.

Dave
 
D

Designingsally

dave i tired this didnt work. can u help me out?

Sub jf()

Dim lList As Long
Dim oRng As Range

For lList = ActiveDocument.Lists.Count To 1 Step -1
Set oRng = ActiveDocument.Lists(lList).ListParagraphs(1).Range
With oRng
.Collapse Direction:=wdCollapseStart
.MoveStart Unit:=wdSentence, Count:=-1
.MoveEnd Unit:=wdCharacter, Count:=-1
If .Characters.Last <> ":" Then
.InsertAfter Text:=":"
End If
If InStr(1, .Text, "various") Then
ActiveDocument.comments.Add Range:=oRng, Text:="AVOID"
If InStr(1, .Text, "as follows") Then
ActiveDocument.comments.Add Range:=oRng, Text:="AVOID"
End If
End If
End With
Next lList




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