I want to connect a line between a oval shape and a grouped shape. The following is the vba code in excel 2007 that I try but not work due to the grouped shape.
Please help me for this.
Sub test2()
AddConnectorBetweenShapes msoConnectorStraight, ActiveSheet.Shapes("Oval 9"), ActiveSheet.Shapes("Group 14")
End Sub
Function AddConnectorBetweenShapes(ConnectorType As MsoConnectorType, _
oBeginShape As Shape, oEndShape As Shape) As Shape
'The ConnectorType can be one of three constants - msoConnectorCurve, msoConnectorElbow, or msoConnectorStraight.
Const TOP_SIDE As Integer = 1
Const BOTTOM_SIDE As Integer = 3
Dim oConnector As Shape
Dim x1 As Single
Dim x2 As Single
Dim y1 As Single
Dim y2 As Single
With oBeginShape
x1 = .Left + .Width / 2
y1 = .Top + .Height
End With
With oEndShape
x2 = .Left + .Width / 2
y2 = .Top
End With
If CInt(Application.Version) < 12 Then
x2 = x2 - x1
y2 = y2 - y1
End If
Set oConnector = ActiveSheet.Shapes.AddConnector(ConnectorType, x1, y1, x2, y2)
oConnector.ConnectorFormat.BeginConnect oBeginShape, BOTTOM_SIDE
oConnector.ConnectorFormat.EndConnect oEndShape, TOP_SIDE
oConnector.RerouteConnections
Set AddConnectorBetweenShapes = oConnector
Set oConnector = Nothing
End Function