Bad X and Y values from MouseOver event for embedded chart

Rohan

New Member
Joined
Aug 14, 2002
Messages
3
Excel 2002 on Windows XP

I have added a rectangle to an embedded chart (the only thing in the chart is the rectangle):

Code:
Application.Worksheets(1).ChartObjects.Add (Left:=20, Width:=375, Top:=40, Height:=225)

With Application.Worksheets(1).ChartObjects(1).Chart.Shapes.AddShape(Type:=msoShapeRectangle, Left:=20, Top:=60, Width:=40, Height:=100)
    .Fill.Visible = msoFalse
End With
I have a MouseOver event for the chart which returns the X and Y values (relative to the embedded chart) of the mouse pointer.

However, the X and Y values returned by my MouseOver event are strange:

1. The rectangle I created should have, and does have, its top left corner at (20,60), but the X and Y values returned by my MouseOver event do not give the correct values. This is the same for other corners of the rectangle.

2. I have determined the height of my chart:

Code:
Application.Worksheets(1).ChartObjects(1).Height

If I place the mouse ponter at the bottom of my chart then the Y value returned by my MouseOver event is greater than the Height of the chart. This is the same for the width of the chart.

I would like my MouseOver event to return the correct X and Y values, or a way to transform the MouseOver X and Y values to the correct values. Does anyone know how to do this?

Thanks
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,203,756
Messages
6,057,161
Members
444,908
Latest member
Jayrey

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top