【发布时间】:2015-11-04 17:10:27
【问题描述】:
我正在开发一种自定义工具,该工具可以为给定的演示文稿生成自定义的讲师注释。我在处理演示文稿时遇到问题,其中幻灯片上基本上没有 Title 对象然后我运行代码,它使用 .
双向传递我的 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
【问题讨论】:
标签: vba powerpoint