Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2005

Tip: Looking for answers? Try searching our database.

Adding a bullet in front of each paragraph

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve D - 10 Feb 2005 00:50 GMT
Hi all...what approach would you suggest for adding a bullet character and
two spaces ("?  ") in front of each selected paragraph in a document? (I
don't want to use a list style or the "Bullets" toolbar button because I'm
pasting the paragraphs into an Excel worksheet cell)

So far, I've successfully added bullet in front of all paragraphs with the
following code using Find/Replace (mostly from Macro recorder). The code
individually inserts the bullet at the beginning of the doc (because F/R
didn't find that one) and then individually removes the bullet and spaces
from the end of the doc (because F/R added a superfluous bullet at the end).

I want to now add bullets only to selected paragraphs. I need to cover the
corner-case where the first paragraph may be selected and a Find/Replace
won't work on it.

Any help greatly appreciated!
Steve

Sub AddBullets()
   Selection.HomeKey Unit:=wdStory
   Selection.Find.ClearFormatting
   Selection.Find.Replacement.ClearFormatting

   With Selection.Find
       .Text = "^p"
       .Replacement.Text = "^p" & ChrW(9642) & "  "
       .Forward = True
       .Wrap = wdFindContinue
       .Format = False
       .MatchCase = False
       .MatchWholeWord = False
       .MatchWildcards = False
       .MatchSoundsLike = False
       .MatchAllWordForms = False
   End With

   Selection.Find.Execute Replace:=wdReplaceAll

   Selection.HomeKey Unit:=wdStory
   Selection.TypeText Text:=ChrW(9642) & "  "

   Selection.EndKey Unit:=wdStory
   Selection.TypeBackspace
   Selection.TypeBackspace
   Selection.TypeBackspace
   Selection.TypeBackspace
End Sub
Jonathan West - 10 Feb 2005 01:13 GMT
Hi Steve,

You do much the same as you have already done, but you set the Wrap property
to wdFindStop. This restricts the replace to the range originally selected.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

> Hi all...what approach would you suggest for adding a bullet character and
> two spaces ("?  ") in front of each selected paragraph in a document? (I
[quoted text clipped - 44 lines]
>    Selection.TypeBackspace
> End Sub
Klaus Linke - 10 Feb 2005 03:54 GMT
Hi Steve,

Might be easier to loop the paragraphs in the selection:

Dim p As Paragraph
For Each p In Selection.Paragraphs
   p.Range.InsertBefore ChrW(9642) & "  "
Next p

If you don't want the bullet to pick up manual formatting from the paragraph,
you'd need to add some code.
Say, set back the first three characters to "Default Paragraph Font".

Regards,
Klaus
Steven Drenker - 10 Feb 2005 07:28 GMT
Thanks, Klaus...very simple and straightforward.
Steve

> Hi Steve,
>
[quoted text clipped - 11 lines]
> Regards,
> Klaus
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.