powerpoint - Powerpoint Notes 部分格式化 VBA
问题描述
使用以下代码将每张幻灯片的注释部分格式化为带图的项目符号列表几乎每次都有效,但在选择的演示文稿中会出现错误:
占位符(未知成员):整数超出范围。2 不在 1 到 1 的有效范围内。
这似乎与任何数量的幻灯片无关,无论注释部分是否已包含文本等。
Sub Button1()
Dim intSlide As Integer
With ActivePresentation
For intSlide = 1 To .Slides.Count
With ActivePresentation.Slides(intSlide).NotesPage. _
Shapes.Placeholders(2).TextFrame.TextRange
With .ParagraphFormat.Bullet
.Type = ppBulletPicture
.Picture ("/Applications/Microsoft Office/picture.JPG")
.RelativeSize = 1.4
End With
End With
Next intSlide
End With
End Sub
解决方案
我很好奇您为什么不只是使用程序界面来设置 Notes Master 中的项目符号。这比编写 VBA 容易得多。
如果注释页面只有 1 个占位符而不是 2 个,则会发生该错误。这是一个更强大的例程,用于检查形状类型以及它是否实际包含文本:
Sub Button1()
Dim oSlide As Slide
Dim oShape As Shape
For Each oSlide In ActivePresentation.Slides
For Each oShape In oSlide.NotesPage.Shapes
If oShape.Type = msoPlaceholder Then
If oShape.PlaceholderFormat.Type = ppPlaceholderBody Then
If oShape.HasTextFrame Then
If oShape.TextFrame.HasText Then
With oShape.TextFrame.TextRange.ParagraphFormat.Bullet
.Type = ppBulletPicture
.Picture ("C:/picture.png")
.RelativeSize = 1.4
End With
End If
End If
End If
End If
Next oShape
Next oSlide
End Sub
推荐阅读
- java - Java - 如何获取字符串中所有可能的字母组合?
- shell - 如何在不使用配置文件和 RC 文件的情况下自动执行 shell 后执行内置 shell?
- swift - Swift:如何使用时区缩写解析日期和时间字符串?
- java - Binary tree insertion problem.....insert() only putting new Nodes in the child of root nodes
- php - FCM Push for iOS 错误 InvalidRegistration
- python - 如何简化此代码并删除 if-else 块?
- python - 芹菜和烧瓶,同一个芹菜应用实例
- python - 过滤数据时出现内存错误
- python - 使用 Scikit Learn 查找集群的关键词
- azure - 从 VS Code 部署 Azure 函数 - 成功但在门户中不可见