【问题标题】:Powerpoint - VBA Only - Insert custom bullets listPowerpoint - 仅限 VBA - 插入自定义项目符号列表
【发布时间】:2019-10-16 18:19:08
【问题描述】:

希望你做得很好。 我正在使用 VBA 代码(仅,不是 XML)在所选对象(文本框、形状等)中插入自定义项目符号列表,例如 我尝试了以下代码:

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

代码当前无法正常工作。 你有什么想法? 谢谢。纳克索斯

【问题讨论】:

  • 请编辑问题以解释*如何代码“不起作用”。

标签: vba powerpoint bullet


【解决方案1】:

您的代码不是必需的。此编号样式已内置在 PowerPoint 中。这是应用它的代码:

Sub NumberStyle()
  With ActiveWindow.Selection.ShapeRange(1).TextFrame2. _
    TextRange.ParagraphFormat.Bullet
    .Type = msoBulletNumbered
    .Style = msoBulletCircleNumWdBlackPlain
  End With
End Sub

这是我解释 PowerPoint 编号样式的文章:OOXML Hacking: PowerPoint Numbering Styles

【讨论】:

  • 我知道。我发布这个问题的原因是因为我需要在另一种情况下使用它,尤其是另一种字体。
【解决方案2】:

经过几次尝试,我找到了代码,如果有人需要,请在下面找到。

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

【讨论】:

    猜你喜欢
    • 2018-10-07
    • 1970-01-01
    • 2013-02-28
    • 1970-01-01
    • 1970-01-01
    • 2012-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多