[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.excel.programming

Application.onKey non-functioning

Madhan

12/12/2006 11:58:00 AM

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.
5 Answers

Madhan

12/12/2006 12:11:00 PM

0

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.

Martin Fishlock

12/12/2006 1:38:00 PM

0

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.

Madhan

12/12/2006 2:46:00 PM

0

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.

NickHK

12/13/2006 3:32:00 AM

0

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" <Madhan@discussions.microsoft.com> wrote in message
news:01223803-CE56-4C66-9CBD-F588F0153E40@microsoft.com...
> 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.


Martin Fishlock

12/13/2006 3:35:00 AM

0

Madhan,

I'm a little at a loss at what you are trying to do.

You activate the onkeys and then you process the keys with the specified
subroutines.

Why is it not working?

For example what is the code you have for the moveLeft?

--
Hope this helps
Martin Fishlock
Please do not forget to rate this reply.


"Madhan" wrote:

> 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.