Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Line Start and End Coordinates

I have a line on the screen (shape). I would like to select it and get the
starting and ending coordinates of the line. TIA, James


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Line Start and End Coordinates

Hi!

"Zone" wrote:

I have a line on the screen (shape). I would like to select it and get the
starting and ending coordinates of the line. TIA, James


I hope that next code help you a little.

ActiveSheet.Shapes(1).Select 'if you have only one line
Range("A1").Value = Selection.ShapeRange.Item(1).Left
Range("A2").Value = Selection.ShapeRange.Item(1).Width
Range("A3").Value = Selection.ShapeRange.Item(1).Top
Range("A4").Value = Selection.ShapeRange.Item(1).Height

Regards,
Kari J Keinonen
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Line Start and End Coordinates

The "flips" help work out which pair of corners of the imaginary rectangle,
that surround the line, represent the correct diagonal. (I tried to make
that short!)

Sub test()
Dim bHflip As Boolean, bVflip As Boolean
Dim nBegin As Long, nEnd As Long
Dim shp As Shape
Dim aC(1 To 4, 1 To 2) As Double

Set shp = ActiveSheet.Shapes("Line 1")
With shp
aC(1, 1) = .Left: aC(1, 2) = .Top
aC(2, 1) = .Left + .Width: aC(2, 2) = .Top
aC(3, 1) = .Left: aC(3, 2) = .Top + .Height
aC(4, 1) = .Left + .Width: aC(4, 2) = .Top + .Height

bHflip = .HorizontalFlip
bVflip = .VerticalFlip
End With

If bHflip = bVflip Then
If bVflip = False Then
' down to right
nBegin = 1: nEnd = 4
Else
' up to left
nBegin = 4: nEnd = 1
End If
ElseIf bHflip = False Then
' up to right
nBegin = 3: nEnd = 2
Else
' down to left
nBegin = 2: nEnd = 3
End If

Debug.Print "Begin X:Y", "End X:Y"
Debug.Print aC(nBegin, 1); aC(nBegin, 2), aC(nEnd, 1); aC(nEnd, 2)

End Sub

Regards,
Peter T


"Zone" wrote in message
...
I have a line on the screen (shape). I would like to select it and get

the
starting and ending coordinates of the line. TIA, James




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Line Start and End Coordinates

Thanks very much, Peter and Kari. Your replies are very helpful to me.
James

"Peter T" <peter_t@discussions wrote in message
...
The "flips" help work out which pair of corners of the imaginary
rectangle,
that surround the line, represent the correct diagonal. (I tried to make
that short!)

Sub test()
Dim bHflip As Boolean, bVflip As Boolean
Dim nBegin As Long, nEnd As Long
Dim shp As Shape
Dim aC(1 To 4, 1 To 2) As Double

Set shp = ActiveSheet.Shapes("Line 1")
With shp
aC(1, 1) = .Left: aC(1, 2) = .Top
aC(2, 1) = .Left + .Width: aC(2, 2) = .Top
aC(3, 1) = .Left: aC(3, 2) = .Top + .Height
aC(4, 1) = .Left + .Width: aC(4, 2) = .Top + .Height

bHflip = .HorizontalFlip
bVflip = .VerticalFlip
End With

If bHflip = bVflip Then
If bVflip = False Then
' down to right
nBegin = 1: nEnd = 4
Else
' up to left
nBegin = 4: nEnd = 1
End If
ElseIf bHflip = False Then
' up to right
nBegin = 3: nEnd = 2
Else
' down to left
nBegin = 2: nEnd = 3
End If

Debug.Print "Begin X:Y", "End X:Y"
Debug.Print aC(nBegin, 1); aC(nBegin, 2), aC(nEnd, 1); aC(nEnd, 2)

End Sub

Regards,
Peter T


"Zone" wrote in message
...
I have a line on the screen (shape). I would like to select it and get

the
starting and ending coordinates of the line. TIA, James






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
Showing x,y coordinates of a line Smylegirl Charts and Charting in Excel 12 May 2nd 07 10:08 PM
code to go to start of line BorisS Excel Programming 1 September 18th 06 07:27 AM
Convert point coordinates - pixel coordinates Zorro[_3_] Excel Programming 1 June 1st 06 03:26 AM
Simple way to convert UTM ED50 coordinates to decimal coordinates? Dan[_38_] Excel Programming 8 July 11th 04 04:54 PM
Converting MouseDown Coordinates to Chart Point Coordinates Steve[_50_] Excel Programming 3 December 2nd 03 06:48 PM


All times are GMT +1. The time now is 11:45 PM.

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

About Us

"It's about Microsoft Excel"