Pixel position of cell

G

Guest

Hi, I'm trying to get the pixel position of the active cell (or any cell for
that matter) so I can position the mouse cursor over it. So far I have worked
out Application.Left gives the the position of the main window,
Application.ActiveWindow.Left gives the position of the spreadsheet window
but that is relative to the client area of the main window. I'm missing how
do I get the position of the client area (the main window minus the borders,
and toolbars, etc)?

Also, I can get the position of the cell, but that is relative to the left
of the first cell, how do I get it relative to the window?

Thanks,
Gary
 
M

Mike Woodhouse

Hi, I'm trying to get the pixel position of the active cell (or any cell for
that matter) so I can position the mouse cursor over it. So far I have worked
out Application.Left gives the the position of the main window,
Application.ActiveWindow.Left gives the position of the spreadsheet window
but that is relative to the client area of the main window. I'm missing how
do I get the position of the client area (the main window minus the borders,
and toolbars, etc)?

Also, I can get the position of the cell, but that is relative to the left
of the first cell, how do I get it relative to the window?

Have you looked at the .Top/.Left/.Height/.Width properties of the
Range object? I.e.
 
M

Mike Woodhouse

Range object? I.e.

(Oops : premature "Send" button there)

Dim itsTop As Single, itsLeft As Single

' Assuming Selection is a single cell, suitable checks omitted
With Selection
itsTop = .Top
itsLeft = .Left
End With


HTH,

Mike
 

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