Yevgeniy
.
Would you please be kind enough to share with us the reason that you
are trying to receive a Windows message?
Regards,
Stratos
I want to know when a spreadsheet cell has been editing
-----Original Message-----
Hi Yevgeniy,
Regards,
Stratos
.
If you want to do something if a cell *has just been* edited and the
user has activated another cell, you may use a built-in event; something
like:
---------------------------
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
End Sub
---------------------------
If again you want to do something while a cell *is being* edited then
you will have to seek solution to more complicated techniques which, due
to the inherit complexity of Excel as a MDI application, all have
disadvantages.
One technique would be to use a 'system timer' and call getkeystate (or
similar) every some milliseconds. This would allow you to read all key
input and their target cell. However, it wouldn't allow you to intercept
a keyboard-originated windows message.
A second technique would be to subclass the target worksheet (the
respective MDI-child window, I mean). If you have tried to subclass a
MDI application using VB before, you will know that this is not as easy
as it seams it theory. You could built however a 'subclasser' component
to make things slightly better. Having subclassed the spreadsheet window
you will be able to both receive and intercept/stop most
keyboard-related messages.
A third way would be to built a windows 'hook' on all keyboard input to
Excel's input thread, or more specifically a hook-chain. In this case as
well you will need to use an external component to achieve reliable
operation for your application. You can again both read and intercept
messages.
In my opinion, the best solution would be to use the first, built-in
solution, do a validation on the input and do whatever you want after
it.
HTH
Stratos