VBA PowerPoint幻灯片标题

史密斯米8

我正在使用一个自定义工具,该工具可以为给定的演示文稿生成自定义的Instructor笔记。我在处理演示文稿时遇到问题,该演示文稿上的幻灯片基本上没有标题对象。然后我遍历代码,它将if语句与双向传递。

我将代码简化为基本知识,以使其尽可能地容易。

我的测试课程有一个正常的幻灯片,其中已填充了文本占位符,下一张幻灯片是没有标题文本框的徽标幻灯片,只有版权信息和徽标(这是有问题的幻灯片),然后是另一张幻灯片标题占位符存在,但留空。

如何检查单个幻灯片以确保标题占位符存在?

Public Sub GetTitle()
    Dim pres As Presentation    'PowerPoint presentation
    Dim sld As Slide            'Individual slide
    Dim shp As Shape            'EIAG Text Shape
    Dim ShpType As String       'Shape Type
    Dim SldTitle As String      'Slide TITLE

    'Go through each slide object
    Set pres = ActivePresentation
    For Each sld In ActivePresentation.Slides.Range
    On Error Resume Next
        If sld.Shapes(1).PlaceholderFormat.Type = ppPlaceholderCenterTitle Or sld.Shapes(1).PlaceholderFormat.Type = ppPlaceholderTitle Then
            If sld.Shapes.Title.TextFrame.TextRange <> "" Then
                SldTitle = sld.Shapes.Title.TextFrame.TextRange
                Debug.Print SldTitle & " - Slide: " & CStr(sld.SlideNumber)
            Else
                Debug.Print "BLANK TITLE - Slide: " & CStr(sld.SlideNumber)
            End If
        Else
            ShpType = sld.Shapes.Item(1).Type
            Debug.Print ShpType & "Not Processed There is no Title object"
        End If
    Next sld
End Sub
杰米·加洛奇(Jamie Garroch)-MVP

您可以使用Shapes Collection的HastTitle方法检查幻灯片是否具有标题占位符:

If sld.Shapes.HasTitle then

您也不应依赖标题占位符为形状1,而应遍历幻灯片上的所有形状,并按如下方式检查每个形状:

Option Explicit

' Function to return an array of title texts from a presentation
' Written by Jamie Garroch at http://youpresent.co.uk
' Inputs : None
' Outputs : Array of title strings
Function GetTitlesArr() As Variant
  Dim oSld As Slide
  Dim oShp As Shape
  Dim iCounter As Integer
  Dim arrTitles() As String
  For Each oSld In ActivePresentation.Slides
    For Each oShp In oSld.Shapes
      With oShp
        If .Type = msoPlaceholder Then
          Select Case .PlaceholderFormat.Type
            Case ppPlaceholderCenterTitle, ppPlaceholderTitle
              ReDim Preserve arrTitles(iCounter)
              arrTitles(iCounter) = oShp.TextFrame.TextRange.Text
              iCounter = iCounter + 1
          End Select
        End If
      End With
    Next
  Next
  GetTitlesArr = arrTitles
End Function

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

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

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

从Access VBA填充Powerpoint幻灯片

来自分类Dev

PowerPoint VBA选择幻灯片

来自分类Dev

VBA用于大写标题幻灯片

来自分类Dev

在Powerpoint VBA编辑器中查看幻灯片标题

来自分类Dev

Powerpoint 2010 VBA:不要为带有特定标题的幻灯片编号

来自分类Dev

VBA Powerpoint按名称选择幻灯片

来自分类Dev

PowerPoint VBA导出某些幻灯片到pdf

来自分类Dev

PowerPoint VBA宏可跳过幻灯片上的动画

来自分类Dev

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

来自分类Dev

Excel VBA在PowerPoint中复制幻灯片

来自分类Dev

PowerPoint VBA导出某些幻灯片到pdf

来自分类Dev

PowerPoint VBA创建和保存幻灯片

来自分类Dev

如何使用VBA动态引用PowerPoint幻灯片

来自分类Dev

VBA 中的 Powerpoint 幻灯片计数变量

来自分类Dev

VBA 不循环任何 PowerPoint 幻灯片

来自分类Dev

PowerPoint VBA代码将焦点重新带到正在运行的PowerPoint幻灯片放映中

来自分类Dev

使用VBA更改Powerpoint 2013中幻灯片元素的颜色

来自分类Dev

使用vba在PowerPoint 2007中的幻灯片上定位图像

来自分类Dev

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

来自分类Dev

如何通过Access VBA在Powerpoint中添加幻灯片,仅使其最小化

来自分类Dev

使用VBA在excel中的每张幻灯片上创建带有多个图表的Powerpoint

来自分类Dev

使用vba在PowerPoint 2007中的幻灯片上定位图像

来自分类Dev

在VBA中打印目录时忽略隐藏的幻灯片-Powerpoint

来自分类Dev

Powerpoint VBA将带有关键字的幻灯片另存为JPEG

来自分类Dev

如何通过Access VBA在Powerpoint中添加幻灯片,仅使其最小化

来自分类Dev

如何在 VBA (PowerPoint) 中的随机幻灯片上检查文本框中的文本?

来自分类Dev

VBA Powerpoint:循环并重命名所有幻灯片

来自分类Dev

如何添加PowerPoint幻灯片标题?

来自分类Dev

使用母版在VBA中为PowerPoint 2010创建具有自定义布局的新幻灯片

Related 相关文章

  1. 1

    从Access VBA填充Powerpoint幻灯片

  2. 2

    PowerPoint VBA选择幻灯片

  3. 3

    VBA用于大写标题幻灯片

  4. 4

    在Powerpoint VBA编辑器中查看幻灯片标题

  5. 5

    Powerpoint 2010 VBA:不要为带有特定标题的幻灯片编号

  6. 6

    VBA Powerpoint按名称选择幻灯片

  7. 7

    PowerPoint VBA导出某些幻灯片到pdf

  8. 8

    PowerPoint VBA宏可跳过幻灯片上的动画

  9. 9

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

  10. 10

    Excel VBA在PowerPoint中复制幻灯片

  11. 11

    PowerPoint VBA导出某些幻灯片到pdf

  12. 12

    PowerPoint VBA创建和保存幻灯片

  13. 13

    如何使用VBA动态引用PowerPoint幻灯片

  14. 14

    VBA 中的 Powerpoint 幻灯片计数变量

  15. 15

    VBA 不循环任何 PowerPoint 幻灯片

  16. 16

    PowerPoint VBA代码将焦点重新带到正在运行的PowerPoint幻灯片放映中

  17. 17

    使用VBA更改Powerpoint 2013中幻灯片元素的颜色

  18. 18

    使用vba在PowerPoint 2007中的幻灯片上定位图像

  19. 19

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

  20. 20

    如何通过Access VBA在Powerpoint中添加幻灯片,仅使其最小化

  21. 21

    使用VBA在excel中的每张幻灯片上创建带有多个图表的Powerpoint

  22. 22

    使用vba在PowerPoint 2007中的幻灯片上定位图像

  23. 23

    在VBA中打印目录时忽略隐藏的幻灯片-Powerpoint

  24. 24

    Powerpoint VBA将带有关键字的幻灯片另存为JPEG

  25. 25

    如何通过Access VBA在Powerpoint中添加幻灯片,仅使其最小化

  26. 26

    如何在 VBA (PowerPoint) 中的随机幻灯片上检查文本框中的文本?

  27. 27

    VBA Powerpoint:循环并重命名所有幻灯片

  28. 28

    如何添加PowerPoint幻灯片标题?

  29. 29

    使用母版在VBA中为PowerPoint 2010创建具有自定义布局的新幻灯片

热门标签

归档