对于特定幻灯片中的每个形状-PowerPoint VBA

问题描述 投票:0回答:1
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

我正在尝试使用幻灯片索引来识别特定幻灯片中是否存在名为CA1的形状。但是我遇到运行时错误:对象不支持此属性。

vba powerpoint powerpoint-vba
1个回答
1
投票

您正在枚举演示文稿中的幻灯片,而不是形状。您应该在幻灯片中枚举形状:

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
© www.soinside.com 2019 - 2024. All rights reserved.