Solved

Macro to replace bullet char with bullet style and keep paragraph text bold

Posted on 2007-03-19
4
2,464 Views
Last Modified: 2008-01-09
Word 2003 macro
I'm replacing a bullet char with the List Bullet Style.  My macro works, but the text of the paragraph is bold.  After I run my macro the text is no longer bold.  Can you show me how to change the macro to keep the paragraph text bold?
Sub ConvertBulletChar()
    Const BulletStyle As String = "List Bullet"
    Dim Para As Paragraph
    Dim BulletChar As String
    Dim s As String
   
    BulletChar = Chr$(149)
   
    With ActiveDocument
        For Each Para In .Paragraphs
            With Para
                s = Mid$(.Range.Text, 1, 1)
                If InStr(1, BulletChar, s) Then
                    .Style = BulletStyle
                                       
                End If
            End With
        Next
    End With
End Sub
0
Comment
Question by:phil1429
  • 2
4 Comments
 

Expert Comment

by:DenisMLawlor
ID: 18752532
Hi,

I think the change is to do with the format of the ListBullet style. I suggest you go to Format, Style and then check the settings for List Bullet Style, and change formatting to bold.

Hope this helps

Denis
0
 
LVL 7

Accepted Solution

by:
gbahri earned 250 total points
ID: 18754093
Hi phil429,

Here is a code that replaces bullet char and apply Bullet list without changing the formatting of paragraph.

===========================================================================
Sub ConvertBulletChar()
    Const BulletStyle As String = "List Bullet"
    Dim Para As Paragraph
    Dim BulletChar As String
    Dim s As String
   
    BulletChar = Chr$(149)
   
    With ActiveDocument
        For Each Para In .Paragraphs
            With Para
                s = Mid$(.Range.Text, 1, 1)
                If InStr(1, BulletChar, s) Then
                    .Range.Characters.Item(1).Delete    ' Removes 1st char of Paragraph chr(149)
                    .Range.ListFormat.ApplyListTemplate ListTemplate:=ListGalleries( _
        wdBulletGallery).ListTemplates(1), ContinuePreviousList:=False, ApplyTo:= _
        wdListApplyToWholeList, DefaultListBehavior:=wdWord9ListBehavior  ' Apply bullet list
                                     
                End If
            End With
        Next
    End With
End Sub

===========================================================================

Hope, this serves your purpose,

thanks,

GBahri

0
 

Author Comment

by:phil1429
ID: 18756553
That's great and I like how you got rid of the original bullet.  I was removing it later with much less finesse.  My final job on these bullets is to change the format.  Now, this part of my macro removes the bold text of the paragraph.  Any more great ideas?  Also, this document comes from Crystal Reports.  I can have the designer in Crystal do something different with the bullets.  Should I ask for the bullets as an asterisk and take advantage of autoformatting?

Sub SetBulletStyle()

Dim oLT As ListTemplate
Dim oLL As ListLevel

    For Each oLT In ActiveDocument.ListTemplates
    With oLT
   
    For Each oLL In oLT.ListLevels
        If oLL.NumberStyle = wdListNumberStyleBullet Then
            With oLL
                .NumberFormat = ChrW(61607)
                .TrailingCharacter = wdTrailingTab
                .NumberStyle = wdListNumberStyleBullet
                .NumberPosition = InchesToPoints(0)
                .Alignment = wdListLevelAlignLeft
                .TextPosition = InchesToPoints(0.25)
                .TabPosition = InchesToPoints(0.25)
                .ResetOnHigher = 0
                .StartAt = 1
                .Font.Name = "Wingdings"
                .LinkedStyle = "List Bullet"
            End With
        End If
    Next oLL
    Next oLT

End Sub
0
 

Author Comment

by:phil1429
ID: 18756865
I got it.  I just left out  the .LinkedStyle = "List Bullet" line, but any improvements would be appreciated.

Sub SetBulletStyle()

Dim oLT As ListTemplate
Dim oLL As ListLevel

    For Each oLT In ActiveDocument.ListTemplates
    For Each oLL In oLT.ListLevels
        If oLL.NumberStyle = wdListNumberStyleBullet Then
            With oLL
                .NumberFormat = ChrW(61607)
                .TrailingCharacter = wdTrailingTab
                .NumberStyle = wdListNumberStyleBullet
                .NumberPosition = InchesToPoints(0)
                .Alignment = wdListLevelAlignLeft
                .TextPosition = InchesToPoints(0.25)
                .TabPosition = InchesToPoints(0.25)
                .ResetOnHigher = 0
                .StartAt = 1
                .Font.Name = "Wingdings"
            End With
        End If
    Next oLL
    Next oLT

End Sub
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
add bookmark label to 78 documents 2 54
Always hangs on opening 8 66
Header of docx file 17 98
MailMerge VBA DataSource Connection Issue 10 48
I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now