Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Why doesn't OnKey work?
I have the following two subs below. From the help files, it's my
understanding that after running sub "setit", I should be able to do a "Control s" and then sub "doit" will be called. It doesn't work. I have Excel 2003. Am I misunderstanding the usage of ONKEY or what am I doing wrong?? Thanks for any help Sub doit() Dim aa aa = aa End Sub Sub setit() Application.OnKey "^s", "doit" End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Why doesn't OnKey work?
Sub doit()
Dim aa aa = aa MsgBox "In Doit" End Sub Sub setit() Application.OnKey "^s", "doit" End Sub Sub Unsetit() Application.OnKey "^s" End Sub worked fine for me. -- Regards, Tom Ogilvy "Mike" wrote in message ... I have the following two subs below. From the help files, it's my understanding that after running sub "setit", I should be able to do a "Control s" and then sub "doit" will be called. It doesn't work. I have Excel 2003. Am I misunderstanding the usage of ONKEY or what am I doing wrong?? Thanks for any help Sub doit() Dim aa aa = aa End Sub Sub setit() Application.OnKey "^s", "doit" End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Why doesn't OnKey work?
Mike,
I believe the onKey command has to be a continue run mode. You are running it once expecting a key capture. I believe it needs contstant polling. You should have the setit command call itself & code in a keystroke to end the entire process. -- http://HelpExcel.com 516-984-0252 "Mike" wrote: I have the following two subs below. From the help files, it's my understanding that after running sub "setit", I should be able to do a "Control s" and then sub "doit" will be called. It doesn't work. I have Excel 2003. Am I misunderstanding the usage of ONKEY or what am I doing wrong?? Thanks for any help Sub doit() Dim aa aa = aa End Sub Sub setit() Application.OnKey "^s", "doit" End Sub |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Why doesn't OnKey work?
No, that isn't true.
-- Regards, Tom Ogilvy "galimi" wrote in message ... Mike, I believe the onKey command has to be a continue run mode. You are running it once expecting a key capture. I believe it needs contstant polling. You should have the setit command call itself & code in a keystroke to end the entire process. -- http://HelpExcel.com 516-984-0252 "Mike" wrote: I have the following two subs below. From the help files, it's my understanding that after running sub "setit", I should be able to do a "Control s" and then sub "doit" will be called. It doesn't work. I have Excel 2003. Am I misunderstanding the usage of ONKEY or what am I doing wrong?? Thanks for any help Sub doit() Dim aa aa = aa End Sub Sub setit() Application.OnKey "^s", "doit" End Sub |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Why doesn't OnKey work?
Just an added thought, all the code should be in a general module, not in a
worksheet or the thisworkbook module. -- Regards, Tom Ogilvy "Tom Ogilvy" wrote in message ... Sub doit() Dim aa aa = aa MsgBox "In Doit" End Sub Sub setit() Application.OnKey "^s", "doit" End Sub Sub Unsetit() Application.OnKey "^s" End Sub worked fine for me. -- Regards, Tom Ogilvy "Mike" wrote in message ... I have the following two subs below. From the help files, it's my understanding that after running sub "setit", I should be able to do a "Control s" and then sub "doit" will be called. It doesn't work. I have Excel 2003. Am I misunderstanding the usage of ONKEY or what am I doing wrong?? Thanks for any help Sub doit() Dim aa aa = aa End Sub Sub setit() Application.OnKey "^s", "doit" End Sub |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Why doesn't OnKey work?
Works for me. Try replacing aa=aa in your doit routine with
MsgBox "You pressed [Ctrl]+[S]" just to verify that it is (or isn't) happening. I put my code in a regular code module, not in worksheet or workbook modules, and it worked like a champ. Excel 2003, Windows XP Pro. Sub CalledRoutine() MsgBox "You pressed [Ctrl]+[S]" End Sub Sub SetItUp() Application.OnKey "^s", "CalledRoutine" End Sub "Mike" wrote: I have the following two subs below. From the help files, it's my understanding that after running sub "setit", I should be able to do a "Control s" and then sub "doit" will be called. It doesn't work. I have Excel 2003. Am I misunderstanding the usage of ONKEY or what am I doing wrong?? Thanks for any help Sub doit() Dim aa aa = aa End Sub Sub setit() Application.OnKey "^s", "doit" End Sub |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Why doesn't OnKey work?
I thought that "^s" was normally used in keystoke to save a file.
"JLatham" wrote: Works for me. Try replacing aa=aa in your doit routine with MsgBox "You pressed [Ctrl]+[S]" just to verify that it is (or isn't) happening. I put my code in a regular code module, not in worksheet or workbook modules, and it worked like a champ. Excel 2003, Windows XP Pro. Sub CalledRoutine() MsgBox "You pressed [Ctrl]+[S]" End Sub Sub SetItUp() Application.OnKey "^s", "CalledRoutine" End Sub "Mike" wrote: I have the following two subs below. From the help files, it's my understanding that after running sub "setit", I should be able to do a "Control s" and then sub "doit" will be called. It doesn't work. I have Excel 2003. Am I misunderstanding the usage of ONKEY or what am I doing wrong?? Thanks for any help Sub doit() Dim aa aa = aa End Sub Sub setit() Application.OnKey "^s", "doit" End Sub |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Why doesn't OnKey work?
With a little bit more experimenting, it appears that it works if I'm typing
into a WorkSheet but I was hoping that it would work when a Userform had the focus. Hopefull thinking, huh!! "Mike" wrote in message ... I have the following two subs below. From the help files, it's my understanding that after running sub "setit", I should be able to do a "Control s" and then sub "doit" will be called. It doesn't work. I have Excel 2003. Am I misunderstanding the usage of ONKEY or what am I doing wrong?? Thanks for any help Sub doit() Dim aa aa = aa End Sub Sub setit() Application.OnKey "^s", "doit" End Sub |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Why doesn't OnKey work?
but I was hoping that it would work when a Userform had the focus.
Too bad you didn't think to mention that in your original post. -- Jim "Mike" wrote in message ... With a little bit more experimenting, it appears that it works if I'm typing into a WorkSheet but I was hoping that it would work when a Userform had the focus. Hopefull thinking, huh!! "Mike" wrote in message ... I have the following two subs below. From the help files, it's my understanding that after running sub "setit", I should be able to do a "Control s" and then sub "doit" will be called. It doesn't work. I have Excel 2003. Am I misunderstanding the usage of ONKEY or what am I doing wrong?? Thanks for any help Sub doit() Dim aa aa = aa End Sub Sub setit() Application.OnKey "^s", "doit" End Sub |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Why doesn't OnKey work?
You're correct, that is the normal definition. But using the .OnKey function
will change that definition! To set it back to the default, you would use Application.OnKey "^s" without the second parameter. "JLGWhiz" wrote: I thought that "^s" was normally used in keystoke to save a file. "JLatham" wrote: Works for me. Try replacing aa=aa in your doit routine with MsgBox "You pressed [Ctrl]+[S]" just to verify that it is (or isn't) happening. I put my code in a regular code module, not in worksheet or workbook modules, and it worked like a champ. Excel 2003, Windows XP Pro. Sub CalledRoutine() MsgBox "You pressed [Ctrl]+[S]" End Sub Sub SetItUp() Application.OnKey "^s", "CalledRoutine" End Sub "Mike" wrote: I have the following two subs below. From the help files, it's my understanding that after running sub "setit", I should be able to do a "Control s" and then sub "doit" will be called. It doesn't work. I have Excel 2003. Am I misunderstanding the usage of ONKEY or what am I doing wrong?? Thanks for any help Sub doit() Dim aa aa = aa End Sub Sub setit() Application.OnKey "^s", "doit" End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
application.onkey doesn't work within a cell | Excel Programming | |||
Onkey doesn't work | Excel Programming | |||
onkey help | Excel Programming | |||
application.onkey doesn't work | Excel Programming | |||
onkey | Excel Programming |