Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Line Position Drawing Object

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Line Position Drawing Object

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Line Position Drawing Object


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   Report Post  
Posted to microsoft.public.excel.programming
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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Line Position Drawing Object

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Position drawing object relative to cell Horatio J. Bilge, Jr. Excel Discussion (Misc queries) 2 September 29th 08 09:16 PM
Floating Drawing Object CLR Excel Programming 9 June 25th 06 03:40 AM
Drawing Object in a Userform Zone Excel Programming 4 May 9th 06 08:27 PM
Drawing Object Shawn Excel Programming 2 March 2nd 05 03:04 PM
Drawing object references JASon Excel Programming 2 August 28th 03 10:49 PM


All times are GMT +1. The time now is 02:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"