VBA列出PowerPoint演示文稿的所有对象名称

博格米尔·米哈伊洛夫

我正在寻找一种方法,可以通过简单的 VBA 脚本自动列出 PowerPoint 演示文稿中的所有对象名称。我使用多张幻灯片上的选择窗格命名某些对象,并且需要在每张幻灯片上生成所有对象名称的列表。不幸的是,我的知识接近于零,但我设法改编了我在这里找到的脚本

Sub ListAllShapes()

Dim curSlide As Slide
Dim curShape As Shape

For Each curSlide In ActivePresentation.Slides
    Debug.Print curSlide.SlideNumber
    For Each curShape In curSlide.Shapes


                Debug.Print curShape.Name


    Next curShape
Next curSlide
End Sub

该脚本的问题在于它达到了 190 行左右的调试屏幕缓冲区的限制并剪切了形状列表的第一部分。如果可以将调试输出写入外部 txt 文件,那就太好了。

另一种绕过调试行限制的解决方案是放置一个形状名称的过滤器,以便它只打印具有特定前缀的名称。例如,名称以“ph-”开头的所有形状

也欢迎其他解决方案。谢谢。

达伦·巴特鲁普-库克

使用您的代码并按照@SteveRindsberg 的建议 - 输出到文本文件。
此代码将在与您的演示文稿相同的文件夹中创建文件:

Sub ListAllShapes()

    Dim curSlide As Slide
    Dim curShape As Shape
    Dim lFile As Long
    Dim sPath As String

    sPath = ActivePresentation.Path

    lFile = FreeFile

    Open sPath & "\Object Names.txt" For Append As #lFile

    For Each curSlide In ActivePresentation.Slides
        Print #lFile, curSlide.SlideNumber
        For Each curShape In curSlide.Shapes
            If Left(curShape.Name, 3) = "ph-" Then
                Print #lFile, curShape.Name
            End If
        Next curShape
    Next curSlide

    Close #lFile

End Sub

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何从PowerPoint演示文稿中提取所有图像?

从Word VBA编辑PowerPoint演示文稿页脚

删除Powerpoint演示文稿中的命名对象

删除PowerPoint演示文稿中所有未使用的母版幻灯片

使用C#将PowerPoint演示文稿的所有幻灯片放到宽屏模式

如何更改PowerPoint 2010演示文稿中所有图片的格式?

无法使用VBA从Excel打开现有的PowerPoint演示文稿(2016)

从Access VBA打开PowerPoint演示文稿的特定幻灯片

使用VBA和Excel生成Powerpoint演示文稿

保存带有演示文稿的PowerPoint演示文稿时使用文件格式常量

将所有打开的演示文稿以不同的名称保存在地图中

设置Powerpoint演示文稿的语言

Excel 更新 PowerPoint 演示文稿

在Excel中使用VBA从PowerPoint模板创建新的PowerPoint演示文稿

如何更改演示文稿以大写显示所有文本?

列出名称作为 JSON 对象名称

使用Python制作PowerPoint演示文稿?

循环播放Powerpoint演示文稿的选定部分

回形针:如何上载Powerpoint演示文稿文件

有没有办法查看演示文稿演示中使用的所有形状?

VBA Powerpoint,在整个演示文稿中在后台运行定时任务/宏

VBA仅保存第二个打开的PowerPoint演示文稿

在VBA powerpoint中如何将新幻灯片添加到空白演示文稿

如何使用Excel VBA和userform编辑嵌入在Excel中的PowerPoint演示文稿

如何在Excel VBA中获取打开的PowerPoint演示文稿的处理程序

如何使用VBA将文本框添加到PowerPoint演示文稿

如何使用VBA将PowerPoint部分复制到新的演示文稿

VBA运行时错误:将PowerPoint演示文稿另存为PDF

PowerPoint VBA:如何将每张幻灯片单独保存为新演示文稿?