Check if a Connector has the EndConnectedShape VBA PPT

I need to check if a Connector is really connected to a Shape, in other words, does it have any Shape returned by EndConnectedShape. So far I have this, but it gives me an error: Permission denied:

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

There must be something very simple, but I can't figure out what I miss. Any suggestions? Thanks!

Answers


oSh.ConnectorFormat.EndConnected 

returns a boolean value indicating if the end is connected to something: check that before trying to access .EndConnectedShape

NOTE: it's worth spending some time to figure out how to use the Watch window to debug problems like this: if you set a watch on oSh then you can browse its propeties in the Watch window when you get an error, and look for likely avenues to explore...


Need Your Help

ASP.NET Merge: Virtual path 'obal.asax' is not allowed

asp.net msbuild merge

I am doing a Web Deployment of my website and I have the merge assemblies property set to true.