Applying the List Bullet Style on specific paragraphs

S

Steve D

Hello...I want to be able to apply the List Bullet style on all paragraphs
that begin with "*<sp><sp>" and then delete these first three characters
(I'm cleaning up docs from others that don't know about bullets). What's the
best way to do this?

I've automated Find/Replace and find I have to do this in two F/R steps.
First, Find "*<sp><sp>" and replace with "" (empty string") and set the
style of Replace to "List Bullet". Second, leave Find set to "*<sp><sp>",
leave the Replace empty string and clear the Replace style. This then
removes the "*<sp><sp>" strings in each paragraph.

I recorded a macro to do this (below), but the
Selection.Find.Replacement.ParagraphFormat.Borders.Shadow = False command
now creates a border around the changed paragraphs. If I remove this line,
no Find/Replace gets triggered.

Question: Is there an easier way to do this? How about enumerating all the
paragraphs in the doc and looking to see if their first three characters are
"*<sp><sp>". If yes, then set the style of the paragraph to "List Bullet".
What's the best way to parse the first three characters of each paragraph in
the Paragraphs collection?

Thanks for any and all help.
Steve

Sub Macro1()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Style = ActiveDocument.Styles("List Bullet")
Selection.Find.Replacement.ParagraphFormat.Borders.Shadow = False <--
Offending

command??
With Selection.Find
.Text = "- "
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "- "
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
 
H

Helmut Weber

Hi Steve,
seems applying the bullet style removes anything
that could be interpreted as a bullet automatically.

Sub Makro7()
Dim rDcm As Range
Dim rPrg As Paragraph
Set rDcm = ActiveDocument.Range
For Each rPrg In rDcm.Paragraphs
If Left(rPrg, 3) = "* " Then
With ListGalleries(wdBulletGallery)
rPrg.Range.ListFormat.ApplyListTemplate _
ListTemplate:=.ListTemplates(1)
End With
End If
Next
End Sub

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 
S

Steven Drenker

Thanks, Helmut. I didn't realize you could use the Left function on a
paragraph. Very simple.

Steve (in Los Altos, California)
 
H

Helmut Weber

Hi Steve,

if speed is important, then searching for "* " first
and checking if "* " equals the leftmost 3 characters
of the paragraph might be an improvement.

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 

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