View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Line Position Drawing Object

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