Application.onKey non-functioning
Sounds like you need to use a timer to move the selection, dependent on the
value set by the arrow keys. Or stop if ESC was pressed.
NickHK
"Madhan" wrote in message
...
Hi, yes it works. Now, the requirement seems to have changed. The
registration of the key event handlers is expected to work in parallel.
In an infinite loop which iterates through various cells of a worksheet,
whenever the appropriate key is pressed, the direction of the cell
navigation
should change. For example, when I press Down-arrow key, the cell
navigation
should change its current direction and should navigate downwards.
This never happens, since the infinite loop is a tight loop and hence the
key events are not recognised, though you may press the key for many
number
of times.
"Martin Fishlock" wrote:
Madhan
I tried the code below and it worked.
You need to call activateonkey and then you can press the keys and the
message boxes appear. After you are finished call deactivateonkey to
cancel
them.
Sub activateonkey()
Application.OnKey "{ESC}", "moveNone"
Application.OnKey "{UP}", "moveUp"
Application.OnKey "{DOWN}", "moveDown"
Application.OnKey "{LEFT}", "moveLeft"
Application.OnKey "{RIGHT}", "moveRight"
End Sub
Sub deactivateonkey()
Application.OnKey "{ESC}"
Application.OnKey "{UP}"
Application.OnKey "{DOWN}"
Application.OnKey "{LEFT}"
Application.OnKey "{RIGHT}"
End Sub
Sub moveUp()
MsgBox "moveup"
End Sub
Sub moveDown()
MsgBox "movedown"
End Sub
Sub moveLeft()
MsgBox "moveleft"
End Sub
Sub moveRight()
MsgBox "moveRight"
End Sub
Sub moveNone()
MsgBox "moveEscNone"
End Sub
--
Hope this helps
Martin Fishlock
Please do not forget to rate this reply.
"Madhan" wrote:
Hi, I have written a Sub that is triggered when I press CTRL+E (this
act was
recorded using macro recorder). That sub contains the following
statements.
Application.OnKey "{ESC}", "moveNone"
Application.OnKey "{UP}", "moveUp"
Application.OnKey "{DOWN}", "moveDown"
Application.OnKey "{LEFT}", "moveLeft"
Application.OnKey "{RIGHT}", "moveRight"
start
"Martin Fishlock" wrote:
Madhan,
Where are you running the application.onkey code?
Also pls post the code for the onkey entries.
--
Hope this helps
Martin Fishlock
Please do not forget to rate this reply.
"Madhan" wrote:
Hi,
I tried adding more than one Application.onKey entries to capture
up-arrow,
down-arrow, right-arrow and left-arrow keys, but, none of the
procedures
associated with each of the Application.onKey entries are
activated.
I tried using breakpoints and msgbox statement.
Is there a restriction on the number of Application.onKey entries
? Or is
there some other issue ?
Help would definitely be appreciated.
|