How to use mouse events inside an Excel Sheet ?

M

mike

Hi,
I would like to use mouse events (like MouseMove) at
ExcelSheet level.
How can I do that, if I can?
 
B

Bob Phillips

Mike,

What are you trying to do?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
M

mike

Bob,
I'm trying to control mouse movements over an excel sheet.
Specifically: I'd like to trigger an action when I'm over
a specific cell.

Could be possible?
thanks!
 
B

Bob Phillips

The problem is that the mousemovement, which can be done with APIs, return
an x & y co-ordinate relative to the screen, not a cell position.

It might be possible to get the Excel app position and the window position
and work out the cell from all of this, but it sounds more effort than it is
worth.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
M

mike

Well,
If there is a possibility to connect, even across API, a
mouse event with an excel object (application ...),
please, would you tell me how it can be done?
Mike
 
B

Bob Phillips

I can give you some code that shows the mouse x/y position in the statusbar.
As I said, this is the screen co-ordinate, not the Excel relative
co-ordinates.

Is that any use to you (it's complex)?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
M

mike

Thank you Bob,

But, I didn't see the code ... !!!???

I made something in this direction using SetWindowLong,
GetCursorPos, CallWindowProc, but the message received
isn't WM_MOUSEMOVE but a value of 32 and I don't know
which message is that!

If you can send me the code I'd be grateful!
Thanks again,
Mike
 
G

Guest

thanks Bob,

I've written the code by myself.
The only problem which stays is that when arrives at the
upper part of the window hangs and I have to minimize and
maximize the excel window subsequently to reobtain the
control on it.
For your information I have used "RangeFromPoint" excel
function to obtain the range (or the shape) at that
specific screen point.

Thank you again,
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