键入不匹配在Powerpoint VBA中执行Find + Replace

时间:2017-10-02 21:10:26

标签: vba excel-vba powerpoint powerpoint-vba excel

对于PowerPoint VBA来说还是个新手 - 我的印象是,这是用于执行基本查找和放大的样板代码。整个幻灯片放映(在这种情况下是前5张幻灯片)。但是,我在Run-time error 13 - Type mismatch上获得For Each shp In sld.Shapes,我无法弄清楚原因。有什么见解吗?

Dim sld As Slide, shp As Shape, i As Long

For i = 1 To 5
    Set sld = PPT.ActivePresentation.Slides(i)
        For Each shp In sld.Shapes '<- Error here
            If shp.HasTextFrame Then
                If shp.TextFrame.HasText Then
                    shp.TextFrame.TextRange.Text = Replace(shp.TextFrame.TextRange.Text, "LastMonth", "September")
                End If
            End If
        Next shp
Next i

1 个答案:

答案 0 :(得分:2)

Excel Shape与Powerpoint Shape不同:您需要使用PowerPoint库限定声明。

Dim shp as PowerPoint.Shape