有没有办法在整个PowerPoint演示文稿中添加句点,不包括每张幻灯片的标题?
我目前正在使用以下代码,它会在所有内容之后设置一段时间:
Sub AddPeriod()
Dim sld As Slide
Dim shp As Shape
For Each sld In ActivePresentation.Slides
For Each shp In sld.Shapes
shp.TextFrame.TextRange.AddPeriods
Next shp
Next sld
End Sub
答案 0 :(得分:0)
我发现这样做的最简单方法是:
Sub AddPeriod()
Dim sld As Slide
Dim shp As Shape
Dim strTitle As String
For Each sld In ActivePresentation.Slides
If sld.Shapes.HasTitle = True Then 'check if there is a title
strTitle = sld.Shapes.Title.TextFrame.TextRange.Text
Else
strTitle = ""
End If
For Each shp In sld.Shapes
'add periods only if text of shape is not equal to title text.
If strTitle <> shp.TextFrame.TextRange.Text Then
shp.TextFrame.TextRange.AddPeriods
End If
Next shp
Next sld
End Sub
这将检查标题的文本与形状的文本。如果它们相同,则不会添加句点。也许在形状上有某种指示,表明形状是否是标题,但我无法找到它。您需要检查以确保幻灯片具有标题,否则从标题形状的文本中获取字符串将导致错误。