Get chart coordinate

G

Guest

Hi
I have made a X-Y-chart with a map as background in EXCEL and linked that to
a slide in PPT2002.
I would like to click on the map during slideshow and get chart coordinates
or the longitde/latitude for the point. In the end I want to calculate for
example the distance to the closest X-Y-point.
I know how to get the mouse position at click and how to convert pixels to
points, but I can't figure out how to convert the point to chart-coordinates.
Any ideas?

Thanks / boh
 
S

Steve Rindsberg

Hi
I have made a X-Y-chart with a map as background in EXCEL and linked that to
a slide in PPT2002.
I would like to click on the map during slideshow and get chart coordinates
or the longitde/latitude for the point. In the end I want to calculate for
example the distance to the closest X-Y-point.
I know how to get the mouse position at click and how to convert pixels to
points, but I can't figure out how to convert the point to chart-coordinates.
Any ideas?

One relatively simple way out would be to tag the shape with the starting and
ending coordinates included in the map.

For example, one set of tags might be starting/ending latitude. Given a
reference to the shape in oSh, when you create the presentation you could:

Call oSh.Tags.Add("StartLAT","30")
Call oSh.Tags.Add("EndLAT","40")

Now you can do this when the shape's clicked:

' Get the tag and convert it to a long so we can do math
lStartLAT = cLng(oSh.Tags("StartLAT"))

You know oSh.Height so you can work out how many degrees of latitude are
represented by each point on the map shape. Figure out where the user clicked,
subtract the distance from the top of the slide to the top of the shape; the
remainder is the offset into the map.
 
G

Guest

Hi Steve and thanks a lot for your response.
I can see your solution but I think it's an uncertain solution thats depends
on manuel update of the code every time I change my map/data.
I have read somewhere that EXCEL copy the entire source workbook to PPT. If
so, is it possible to get a reference to the EXCEL object "Chart 1" in PPT?
If I have a reference to "Chart 1", it ought to be possible to get
Axes(xlValue).MinimumScale, Axes(xlValue).MaximumScale..... and, with some
math, convert points to chart-coordinates. Am I completely wrong? Or have
someone a good solution to my problem. Thanks in advance / boh


"Steve Rindsberg" skrev:
 
S

Steve Rindsberg

Hi Steve and thanks a lot for your response.
I can see your solution but I think it's an uncertain solution thats depends
on manuel update of the code every time I change my map/data.

That's correct. I wasn't sure how often your maps changed or how big a burden it'd
be to keep the manual info updated.
I have read somewhere that EXCEL copy the entire source workbook to PPT.

When you copy/paste, yes.
so, is it possible to get a reference to the EXCEL object "Chart 1" in PPT?
If I have a reference to "Chart 1", it ought to be possible to get
Axes(xlValue).MinimumScale, Axes(xlValue).MaximumScale..... and, with some
math, convert points to chart-coordinates. Am I completely wrong? Or have
someone a good solution to my problem. Thanks in advance / boh

In theory, you can automate anything to the chart from within PPT that you could do
to it from within Excel. I doubt you'll find a pre-written solution for just this
problem, but have a google for terms like "automate excel" to get some pointers.
There are a few links in the programming section of http://www.pptfaq.com as well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top