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!
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...