This is a rather messy subject. Here are some pointers; no functional
code, sorry.
From the shape you can get the left, top, width, and height. That
means you can get both endpoints. These dimensions are relative to the
chart and are in points.
You can also get the chart's plotarea dimensions. The width
corresponds to the X-Max - X-Min and the height corresponds to Y-Max -
Y-Min. These are in an unspecified measurement system
[If you use chart events and trap the MouseDown and MouseUp events, the
X,Y coordinates are returned in the 'chart client coordinate' system --
whatever that means]
So, if you can sort out all the different measurement systems, you
could either:
Use this one conversion routine (that I can never find when I need it)
to convert the location of any point on the chart into 'Chart element',
'series-index-if-series', and 'point-index-if-series'
Or, you could write your own conversion routine that maps (Axis-Max -
Axis-Min) to PlotArea width for x values (height for y values) and then
intrapolate the position of the line to get the beginning and end
points of the line relative to the values plotted in the chart.
One example of the inconsistent measuring systems: With some chart I
used for testing: Drew a line from the top-left corner of the plotarea
to somewhere-doesn't-matter. The line's top-left coordinate were
(26.25, 40.5). However, the PlotArea Left,Top values were (8,33).
Finally, after writing a MouseUp event procedure and clicking on the
top-left of the plot area, I got x,y values of (40,61).
--
Regards,
Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions