Bhavesh Shaha
Bhavesh Shaha

Reputation: 783

For Each Shape in a specific slide

Sub FindingIfShapeNamesCA1Exists()
Dim shp As Shape
  For Each shp In ActivePresentation.Slides(2)

    If shp.Name = "CA1" Then
    MsgBox "y"
    End If

  Next shp
End Sub

I am trying to identify if a shape named CA1 is present in a particular slide using the slide indexing. However I am getting a run-time error: Object doesn't support this property.

Upvotes: 0

Views: 188

Answers (1)

EylM
EylM

Reputation: 6103

You are enumerating the slides in the presentation, but not the shapes. You should enumerates the Shapes in the slide:

Sub FindingIfShapeNamesCA1Exists()
    Dim shp As Shape      

    For Each shp In ActivePresentation.Slides(2).Shapes
        If shp.Name = "CA1" Then
            MsgBox "y"
        End If
    Next shp        
End Sub

Upvotes: 2

Related Questions