首页 > 解决方案 > 使用 VBA 识别和更改 PowerPoint 中的子弹类型

问题描述

我试图弄清楚如何识别子弹类型并进行更改,即检查整个演示文稿中使用的子弹是否是方形子弹。如果没有,宏应该将项目符号类型更改为方形。

示例:在这张图片中,我想在整个幻灯片中将圆形子弹更改为方形子弹。

子弹转换

标签: vbapowerpoint

解决方案


如果项目符号仅使用本地格式创建,则其他 2 个回复就足够了。如果演示文稿是普通的演示文稿,其中项目符号设置在幻灯片母版中,那些圆形项目符号将像难闻的气味一样不断回来。相反,将幻灯片母版上的项目符号更改为方形,然后重置所有幻灯片以强制更新。这将级别 1、3 和 5 设置为方形项目符号:

Sub ChangeSomeBullets()
  Dim oSlide As Slide
  Dim oShape As Shape

  For Each oShape In ActivePresentation.Designs(1).SlideMaster.Shapes
    If oShape.Type = msoPlaceholder Then
      If oShape.PlaceholderFormat.Type = ppPlaceholderBody Then
        For X = 1 To oShape.TextFrame2.TextRange.Paragraphs.Count
          Select Case X
            Case 1, 3, 5
              With oShape.TextFrame2.TextRange.Paragraphs(X).ParagraphFormat.Bullet
                .Font.Name = "Wingdings"
                .Character = 167
              End With
          End Select
        Next X
      End If
    End If
  Next oShape
  For Each oSlide In ActivePresentation.Slides
    oSlide.CustomLayout = oSlide.CustomLayout
  Next oSlide
End Sub

推荐阅读