View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
JLatham JLatham is offline
external usenet poster
 
Posts: 3,365
Default 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