TomBarsh
Structural
- Jun 20, 2002
- 1,003
I want to use the 'OnKey' VBA command so that some action is taken when a particular key is pressed.
I tried the Excel VBA Help examples, Walkenbach's examples from Power Programming, and a few examples from internet resources. All seemed to use the same basic syntax but it doesn't work for me. Yes, I can use the OnKey command to turn off or restore action. The problem is with directing the action to be taken to a new routine.
For example,
Sub tom1()
Application.OnKey "{F1}", "tom2"
End Sub
'
Sub tom2()
'some action to be taken
End Sub
Gives error message: "The macro "c:\myfile.xls'!tom1' cannot be found."
What I finally found is that the macro (in this case, "tom2") was found if all of the code was in the Personal.xls file. Can this be gotten to work if it's in a different file? I have several other files that serve as my "personal.xls" file and I don't really want to be forced to use this file as well.
Thanks.
I tried the Excel VBA Help examples, Walkenbach's examples from Power Programming, and a few examples from internet resources. All seemed to use the same basic syntax but it doesn't work for me. Yes, I can use the OnKey command to turn off or restore action. The problem is with directing the action to be taken to a new routine.
For example,
Sub tom1()
Application.OnKey "{F1}", "tom2"
End Sub
'
Sub tom2()
'some action to be taken
End Sub
Gives error message: "The macro "c:\myfile.xls'!tom1' cannot be found."
What I finally found is that the macro (in this case, "tom2") was found if all of the code was in the Personal.xls file. Can this be gotten to work if it's in a different file? I have several other files that serve as my "personal.xls" file and I don't really want to be forced to use this file as well.
Thanks.