dwirony
dwirony

Reputation: 5450

Type Mismatch doing a Find+Replace in Powerpoint VBA

Fairly new to PowerPoint VBA - I was under the impression that this was the boilerplate code for doing a basic Find & Replace throughout the slideshow (in this case the first 5 slides). However, I'm getting a Run-time error 13 - Type mismatch on line For Each shp In sld.Shapes and I can't figure out why. Any insight?

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

Upvotes: 1

Views: 235

Answers (1)

Tim Williams
Tim Williams

Reputation: 166755

An Excel Shape is not the same as a Powerpoint Shape: you need to qualify your Declaration with the PowerPoint library.

Dim shp as PowerPoint.Shape

Upvotes: 2

Related Questions