Active Cell Screen Coordinates - Not Mouse Coordinates

mkclhr

New Member
Joined
Nov 8, 2005
Messages
2
Hi, I am trying to find the screen coordinates (top and left) of the active cell. The mouse can be anywhere else on the screen. I can get the active cell's "top and left" coordinates from the cell properties, but these coordinates are relative to the Excel application window - and that's not what I am looking for. I searched through the posts but was unable to find posts related to this.

Thanks,
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
May be possible depending on circumstances. There are all sorts of things that could screw this up. Like changing column widths. I have, for example, been able to simulate a mouseclick in a cell, which requires knowing the screen coordinates - but I was in control of any sheet changes.

Application.Top and Application.Left will give the Excel screen positions, so you could calculate the cell screen position if you know the difference.

eg. Cell A1 Top and Left are both zero, so, in theory you could use Excel.Left as being the A1 cell Left.

The problem is with Top. If the number of toolbars changes the distance between Application.Top and Cell A1 Top will be different.

You have not said what you are trying to achieve. Perhaps there isanother way.
 
Upvote 0
Hi Brian,

Thanks for the reply. I will certainly give this a shot. I was trying to figure out which container (object) would give me the screen coordinates - to the extent I was even now looking at APIs like GetRect, GetFocus etc...

The menu's in the excel application are static, so that should be a constant I can easily factor into the calculation. The Selection property does not recognize custom menu methods hence I was trying to simulate a Right-Click in a cell to force a custom menu command.

BTW - is there a way to enforce triggering a custom menu method using excel's default methods other than having to call the function directly in code?

Regards,
Kashif.
 
Upvote 0
mkclhr said:
The Selection property does not recognize custom menu methods hence I was trying to simulate a Right-Click in a cell to force a custom menu command.

What do you mean?

Are you trying to customize the right click menu?
 
Upvote 0

Forum statistics

Threads
1,206,816
Messages
6,075,036
Members
446,114
Latest member
FadDak

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