Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Application.onKey non-functioning

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Application.onKey non-functioning

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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default interupting excel infintie loops to detect shortcut keypresses

hi
same issue
i got round it very inelegantly with:
setting up a command button
setting the accelerator to the key i wanted to use

the computer can still pick up these keypresses ie alt+k, when it seems to be blind to application.onkey "k","proc"

very irritating. i then set sticky keys on and pressed alt x2, to remove the need to keep pressing alt key with my short cut keys.

i tried putting :Application.SendKeys ("^{break}")
within the infinite loop, but this didnt work for me

any thoughts?
tom

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default interupting excel infintie loops to detect shortcut keypresses

hi
same issue
i got round it very inelegantly with:
setting up a command button
setting the accelerator to the key i wanted to use

the computer can still pick up these keypresses ie alt+k, when it seems to be blind to application.onkey "k","proc"

very irritating. i then set sticky keys on and pressed alt x2, to remove the need to keep pressing alt key with my short cut keys.

i tried putting :Application.SendKeys ("^{break}")
within the infinite loop, but this didnt work for me

any thoughts?
tom

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to apply Application.OnKey dewanna Excel Programming 1 April 7th 06 07:16 AM
Application.OnKey Norman Jones Excel Programming 0 January 27th 05 01:26 AM
Application.OnKey problem R Avery Excel Programming 0 July 8th 04 06:38 PM
application.onkey doesn't work bob Excel Programming 2 May 10th 04 11:06 AM
Application.OnKey problem Phillip Reeves[_2_] Excel Programming 1 January 23rd 04 06:46 PM


All times are GMT +1. The time now is 07:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"