Daniel Clímaco
Daniel Clímaco

Reputation: 85

Change shape visible propertie of a slide range (VBA Macros PowerPoint)

I tested the following code to change the visibility of all shapes with the same name ("a") in each slide from the array...:

Private Sub CommandButton1_Click()
Dim osldR As SlideRange
Set osldR = ActivePresentation.slides.Range(Array(2, 3, 4))
osldR.Shapes("a").Visible = msoFalse
End Sub

But I get this error.

Upvotes: 2

Views: 192

Answers (1)

Domenic
Domenic

Reputation: 8114

Try...

Private Sub CommandButton1_Click()
    Dim osldR As SlideRange
    Dim oSld As Slide
    Dim oShp As Shape
    Set osldR = ActivePresentation.Slides.Range(Array(2, 3, 4))
    For Each oSld In osldR
        For Each oShp In oSld.Shapes
            If oShp.Name = "a" Then
                oShp.Visible = msoFalse
                Exit For 'if there will only be one shape named "a" on a slide
            End If
        Next oShp
    Next oSld
End Sub

Hope this helps!

Upvotes: 1

Related Questions