Search code examples
vbapowerpointbullet

Powerpoint - VBA Only - Insert custom bullets list


Hope you are doing well. I am on a VBA code (only, not XML) to insert a custom bullet list in the selected object (textbox, shape etc.) such as Expected I tried the following code:

Sub CustomBulletsVBAOnly()

With ActiveWindow.Selection.ShapeRange.textFrame
    With .TextFrame2.TextRange.Paragraphs(1)
        .ParagraphFormat.bullet.Font.name = "Webdings"
        .ParagraphFormat.bullet.Character = 140
    End With
    With .TextFrame2.TextRange.Paragraphs(2)
        .ParagraphFormat.bullet.Font.name = "Webdings"
        .ParagraphFormat.bullet.Character = 141
    End With
    With .TextFrame2.TextRange.Paragraphs(3)
        .ParagraphFormat.bullet.Font.name = "Webdings"
        .ParagraphFormat.bullet.Character = 142
    End With
    With .TextFrame2.TextRange.Paragraphs(4)
        .ParagraphFormat.bullet.Font.name = "Webdings"
        .ParagraphFormat.bullet.Character = 143
    End With
    With .TextFrame2.TextRange.Paragraphs(5)
        .ParagraphFormat.bullet.Font.name = "Webdings"
        .ParagraphFormat.bullet.Character = 144
    End With
    With .TextFrame2.TextRange.Paragraphs(6)
        .ParagraphFormat.bullet.Font.name = "Webdings"
        .ParagraphFormat.bullet.Character = 145
    End With
    With .TextFrame2.TextRange.Paragraphs(7)
        .ParagraphFormat.bullet.Font.name = "Webdings"
        .ParagraphFormat.bullet.Character = 146
    End With
    With .TextFrame2.TextRange.Paragraphs(8)
        .ParagraphFormat.bullet.Font.name = "Webdings"
        .ParagraphFormat.bullet.Character = 147
    End With
    With .TextFrame2.TextRange.Paragraphs(9)
        .ParagraphFormat.bullet.Font.name = "Webdings"
        .ParagraphFormat.bullet.Character = 148
    End With

End With
End Sub

The code is currently not working. Do you have any ideas? Thanks. Naxos


Solution

  • After few tries I found the code if someone needs it please find it below.

    Sub InsertCustomBulletList()
     If ActiveWindow.Selection.Type = ppSelectionText Then
         With ActiveWindow.Selection.TextRange
                    With ActiveWindow.Selection.TextRange.Lines(1).ParagraphFormat.bullet
                        .Visible = msoTrue
                        .UseTextColor = msoTrue
                        .Font.name = "Your font"
                        .Character = 0  'Character in ASCII Dec
                        .Font.Color.RGB = RGB(0, 0, 0)
                    End With
                    With ActiveWindow.Selection.TextRange.Lines(2).ParagraphFormat.bullet
                        .Visible = msoTrue
                        .UseTextColor = msoTrue
                        .Font.name = "Your font"
                        .Character = 0  'Character in ASCII Dec
                        .Font.Color.RGB = RGB(0, 0, 0)
                    End With
                    With ActiveWindow.Selection.TextRange.Lines(3).ParagraphFormat.bullet
                        .Visible = msoTrue
                        .UseTextColor = msoTrue
                        .Font.name = "Your font"
                        .Character = 0  'Character in ASCII Dec
                        .Font.Color.RGB = RGB(0, 0, 0)
                    End With
                    With ActiveWindow.Selection.TextRange.Lines(4).ParagraphFormat.bullet
                        .Visible = msoTrue
                        .UseTextColor = msoTrue
                        .Font.name = "Your font"
                        .Character = 0  'Character in ASCII Dec
                        .Font.Color.RGB = RGB(0, 0, 0)
                    End With
                    With ActiveWindow.Selection.TextRange.Lines(5).ParagraphFormat.bullet
                        .Visible = msoTrue
                        .UseTextColor = msoTrue
                        .Font.name = "Your font"
                        .Character = 0  'Character in ASCII Dec
                        .Font.Color.RGB = RGB(0, 0, 0)
                    End With
                    With ActiveWindow.Selection.TextRange.Lines(6).ParagraphFormat.bullet
                        .Visible = msoTrue
                        .UseTextColor = msoTrue
                        .Font.name = "Your font"
                        .Character = 0  'Character in ASCII Dec
                        .Font.Color.RGB = RGB(0, 0, 0)
                    End With
                    With ActiveWindow.Selection.TextRange.Lines(7).ParagraphFormat.bullet
                        .Visible = msoTrue
                        .UseTextColor = msoTrue
                        .Font.name = "Your font"
                        .Character = 0  'Character in ASCII Dec
                        .Font.Color.RGB = RGB(0, 0, 0)
                    End With
                    With ActiveWindow.Selection.TextRange.Lines(8).ParagraphFormat.bullet
                        .Visible = msoTrue
                        .UseTextColor = msoTrue
                        .Font.name = "Your font"
                        .Character = 0  'Character in ASCII Dec
                        .Font.Color.RGB = RGB(0, 0, 0)
                    End With
                    With ActiveWindow.Selection.TextRange.Lines(9).ParagraphFormat.bullet
                        .Visible = msoTrue
                        .UseTextColor = msoTrue
                        .Font.name = "Your font"
                        .Character = 0  'Character in ASCII Dec
                        .Font.Color.RGB = RGB(0, 0, 0)
                    End With
                    With ActiveWindow.Selection.TextRange.Lines(10).ParagraphFormat.bullet
                        .Visible = msoTrue
                        .UseTextColor = msoTrue
                        .Font.name = "Your font"
                        .Character = 0  'Character in ASCII Dec
                        .Font.Color.RGB = RGB(0, 0, 0)
                    End With
                    With ActiveWindow.Selection.TextRange.Lines(11).ParagraphFormat.bullet
                        .Visible = msoTrue
                        .UseTextColor = msoTrue
                        .Font.name = "Your font"
                        .Character = 0  'Character in ASCII Dec
                        .Font.Color.RGB = RGB(0, 0, 0)
                    End With
                    With ActiveWindow.Selection.TextRange.Lines(12).ParagraphFormat.bullet
                        .Visible = msoTrue
                        .UseTextColor = msoTrue
                        .Font.name = "Your font"
                        .Character = 0  'Character in ASCII Dec
                        .Font.Color.RGB = RGB(0, 0, 0)
                   End With
                     With ActiveWindow.Selection.TextRange.Lines(13).ParagraphFormat.bullet
                        .Visible = msoTrue
                        .UseTextColor = msoTrue
                        .Font.name = "Your font"
                        .Character = 0  'Character in ASCII Dec
                        .Font.Color.RGB = RGB(0, 0, 0)
                    End With
                    With ActiveWindow.Selection.TextRange.Lines(14).ParagraphFormat.bullet
                        .Visible = msoTrue
                        .UseTextColor = msoTrue
                        .Font.name = "Your font"
                        .Character = 0  'Character in ASCII Dec
                        .Font.Color.RGB = RGB(0, 0, 0)
                    End With
                    With ActiveWindow.Selection.TextRange.Lines(15).ParagraphFormat.bullet
                        .Visible = msoTrue
                        .UseTextColor = msoTrue
                        .Font.name = "Your font"
                        .Character = 0  'Character in ASCII Dec
                        .Font.Color.RGB = RGB(0, 0, 0)
                    End With
                    With ActiveWindow.Selection.TextRange.Lines(16).ParagraphFormat.bullet
                        .Visible = msoTrue
                        .UseTextColor = msoTrue
                        .Font.name = "Your font"
                        .Character = 0  'Character in ASCII Dec
                        .Font.Color.RGB = RGB(0, 0, 0)
                    End With
                    With ActiveWindow.Selection.TextRange.Lines(17).ParagraphFormat.bullet
                        .Visible = msoTrue
                        .UseTextColor = msoTrue
                        .Font.name = "Your font"
                        .Character = 0  'Character in ASCII Dec
                        .Font.Color.RGB = RGB(0, 0, 0)
                    End With
                    With ActiveWindow.Selection.TextRange.Lines(18).ParagraphFormat.bullet
                        .Visible = msoTrue
                        .UseTextColor = msoTrue
                        .Font.name = "Your font"
                        .Character = 0  'Character in ASCII Dec
                        .Font.Color.RGB = RGB(0, 0, 0)
                    End With
                    With ActiveWindow.Selection.TextRange.Lines(19).ParagraphFormat.bullet
                        .Visible = msoTrue
                        .UseTextColor = msoTrue
                        .Font.name = "Your font"
                        .Character = 0  'Character in ASCII Dec
                        .Font.Color.RGB = RGB(0, 0, 0)
                    End With
                    With ActiveWindow.Selection.TextRange.Lines(20).ParagraphFormat.bullet
                        .Visible = msoTrue
                        .UseTextColor = msoTrue
                        .Font.name = "Your font"
                        .Character = 0  'Character in ASCII Dec
                        .Font.Color.RGB = RGB(0, 0, 0)
                    End With
        End With
     End If
    End Sub