更改幻灯片范围的形状可见属性(VBA 宏 PowerPoint)

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

我测试了以下代码以更改数组中每张幻灯片中具有相同名称 ("a") 的所有形状的可见性...:[=​​13=]

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

但我得到 this error。

尝试...

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

希望对您有所帮助!