Powerpoint - VBA Only - 插入自定义项目符号列表
Powerpoint - VBA Only - Insert custom bullets list
希望你一切顺利。
我正在使用 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
该代码目前无法正常工作。
你有什么想法?
谢谢。纳克索斯
不需要您的代码。此编号样式已内置到 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
经过几次尝试,我找到了代码,如果有人需要,请在下面找到它。
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
希望你一切顺利。
我正在使用 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
该代码目前无法正常工作。 你有什么想法? 谢谢。纳克索斯
不需要您的代码。此编号样式已内置到 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
经过几次尝试,我找到了代码,如果有人需要,请在下面找到它。
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