PDA

View Full Version : Shape Selection Dynamically



jignesh142
02-05-2013, 01:27 AM
i want to make custom flowchart software in the excel and i succeed to make shapes and arrows etc with VBA

now the problem comes when i want to add the elbow arrow between the two shapes which are not aligned.
i can do this with the Activesheets.shapes.addconnector(msoconnectorebow,x1,y1,x2,y2).select

the main thing here is that i don't want to specify the value of x1.y1.x2.y2 in the function but i want to select the two shapes and to draw the arrow dynamically

can anybody help me to activate this command only with vba?

jolivanes
02-05-2013, 02:05 PM
You can use the Left, Top, Width and Height of the selected Shapes.
Use an Offset for the Elbow Top and Left from these figures.
I used this to give me all the coordinates for a bunch of lines. (Type 9)

Sub Get_Coords_A()
Dim ln As Shape
For Each ln In ActiveSheet.Shapes
If ln.Type = 9 Then
With Cells(Rows.Count, "P").End(xlUp)(2)
.Value = ln.Left
.Offset(, 1).Value = ln.Top
.Offset(, 2).Value = ln.Width
.Offset(, 3).Value = ln.Height
End With
End If
Next ln
End Sub

jignesh142
02-05-2013, 08:56 PM
I just want to activate the elbow arrow connector command with vba only

if i activate only this command then it will give me the on screen selection of the shapes to make arrow between them, after words i can change the property of this arrow by vba code

Rest of the matter will be taken care by my code

jignesh142
02-07-2013, 08:42 PM
Any answers?