Previous in Forum: Trojan Alureon Removal   Next in Forum: VBA Excel 2007 Code for Connected Shape Handling
Close
Close
Close
Rate Comments: Nested
Power-User

Join Date: Feb 2011
Location: Shimurali, Westbengal,India
Posts: 119

Add Connector Between Two Shapes/Group Of Shape

09/11/2013 4:56 AM

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

Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Anonymous Poster #1
#1

Re: Add connector between two shapes/group of shape

09/11/2013 6:52 AM

Try Visio instead.

Register to Reply Score 1 for Off Topic
Register to Reply

Previous in Forum: Trojan Alureon Removal   Next in Forum: VBA Excel 2007 Code for Connected Shape Handling

Advertisement