Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have two drawing objects on my sheet--"Line 1" and "Line 2". I want to
programatically move the bottom right end of "Line 2" to join the top left end of "Line 1". All help would be appreciated. Thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Marvin wrote:
I have two drawing objects on my sheet--"Line 1" and "Line 2". I want to programatically move the bottom right end of "Line 2" to join the top left end of "Line 1". All help would be appreciated. Thanks. Hi Marvin With ActiveSheet.Shapes("Line 2") ..Top = ActiveSheet.Shapes("Line 1").Top - .Height ..Left = ActiveSheet.Shapes("Line 1").Left - .Width End With Ken Johnson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi Marvin, In my last reply I assumed that you wanted Line 2 to maintain the same length and orientation so that the whole line moves when it connects with Line 1. After re-reading your post I now see a different interpretation... maybe you want the bottom end of Line 2 to connect with the top left end of Line 1 while Line 2's top left end stays put. If this is the case then the code needs to first determine which Node on Line 2 is the lower one, then move the lower node to the top left end of Line 1... Public Sub Move_Line_Lower_Point() pointsarray1 = _ ActiveSheet.Shapes("Line 2").Nodes(1).Points pointsarray2 = _ ActiveSheet.Shapes("Line 2").Nodes(2).Points If pointsarray1(1, 2) pointsarray2(1, 2) Then ActiveSheet.Shapes("Line 2").Nodes.SetPosition 1, _ ActiveSheet.Shapes("Line 1").Left, _ ActiveSheet.Shapes("Line 1").Top Else: ActiveSheet.Shapes("Line 2").Nodes.SetPosition 2, _ ActiveSheet.Shapes("Line 1").Left, _ ActiveSheet.Shapes("Line 1").Top End If End Sub Ken Johnson |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Ken,
I found that didn't always work depending on the original relative positions of the two lines, eg two similar angled lines one above the other gave me a cross. However there are other implications of using this method that results in changing one of the lines from a true line to a Freeform autoshape. If the line had not already been named from its default will get renamed from say Line 2 to Freeform 2. Alternatively could trap the left & top, right (left + width) & bottom (top + height) positions of the respective lines and change the dimensions of one of the lines as appropriate (width not to be confused with weight). However if I wanted to go there I wouldn't start from here, to coin a phrase. The OP might be better to replace the second line with a connector line (from the autoshapes menu). Record a macro while doing select the connector line select an end connector and drag to connect to the end of the ordinary line Regards, Peter T "Ken Johnson" wrote in message ups.com... Hi Marvin, In my last reply I assumed that you wanted Line 2 to maintain the same length and orientation so that the whole line moves when it connects with Line 1. After re-reading your post I now see a different interpretation... maybe you want the bottom end of Line 2 to connect with the top left end of Line 1 while Line 2's top left end stays put. If this is the case then the code needs to first determine which Node on Line 2 is the lower one, then move the lower node to the top left end of Line 1... Public Sub Move_Line_Lower_Point() pointsarray1 = _ ActiveSheet.Shapes("Line 2").Nodes(1).Points pointsarray2 = _ ActiveSheet.Shapes("Line 2").Nodes(2).Points If pointsarray1(1, 2) pointsarray2(1, 2) Then ActiveSheet.Shapes("Line 2").Nodes.SetPosition 1, _ ActiveSheet.Shapes("Line 1").Left, _ ActiveSheet.Shapes("Line 1").Top Else: ActiveSheet.Shapes("Line 2").Nodes.SetPosition 2, _ ActiveSheet.Shapes("Line 1").Left, _ ActiveSheet.Shapes("Line 1").Top End If End Sub Ken Johnson |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you. This works fine for a line that has not been rotated. If "Line
2" has been rotated, the ends do not match up. "Ken Johnson" wrote: Marvin wrote: I have two drawing objects on my sheet--"Line 1" and "Line 2". I want to programatically move the bottom right end of "Line 2" to join the top left end of "Line 1". All help would be appreciated. Thanks. Hi Marvin With ActiveSheet.Shapes("Line 2") ..Top = ActiveSheet.Shapes("Line 1").Top - .Height ..Left = ActiveSheet.Shapes("Line 1").Left - .Width End With Ken Johnson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Position drawing object relative to cell | Excel Discussion (Misc queries) | |||
Floating Drawing Object | Excel Programming | |||
Drawing Object in a Userform | Excel Programming | |||
Drawing Object | Excel Programming | |||
Drawing object references | Excel Programming |