0

我需要检查一个连接器是否真的连接到一个形状,换句话说,它是否有 EndConnectedShape 返回的任何形状。到目前为止,我有这个,但它给了我一个错误:权限被拒绝:

Sub test()
    Dim oSh, mySh As Shape
    smth = "SomeName"

    For Each oSh In ActivePresentation.Slides(1).Shapes
        If oSh.Connector And oSh.Name = smth Then
            ' In the NEXT line the following error is returned:
            ' oSh.ConnectorFormat.EndConnectedShape = <Permission denied>
            Set mySh = oSh.ConnectorFormat.EndConnectedShape
            If Not IsEmpty(mySh) Then
                oSh.ConnectorFormat.EndConnectedShape.Line.ForeColor.RGB = RGB(255, 0, 0)
            End If
        End If
    Next oSh

End Sub

一定有一些非常简单的东西,但我无法弄清楚我错过了什么。有什么建议么?谢谢!

4

1 回答 1

3
oSh.ConnectorFormat.EndConnected 

返回一个布尔值,指示端是否连接到某物:在尝试访问之前检查 .EndConnectedShape

注意:花一些时间来弄清楚如何使用 Watch 窗口来调试这样的问题是值得的:如果你设置了一个手表,oSh那么当你遇到错误时,你可以在 Watch 窗口中浏览它的属性,并寻找可能的途径探索...

在此处输入图像描述

于 2014-02-28T20:45:10.983 回答