OnKey Method

T

Tha BeatMaker

I need help with the onkey method. I can not get it to work.

I have created a userform, label and macro named UserForm1, lblPress
and Functest respectively. Here is my code. What am I doing wrong?

Private Sub UserForm_Initialize()
Application.OnKey "{F10}", "functest"
End Sub
----------------------------------------------------------------------
Private Sub UserForm_Terminate()
Application.OnKey "{F10}"
End Sub
----------------------------------------------------------------------
Sub functest()
Const conMsg As String = "You have pressed F10"

lblPress.Caption = conMsg

End Su
 
G

Gary's Student

Its hard to advise here, but:

1. make sure your stuff is in the ThisWorkbook module
2. you might need private sub workbook_open() to do the initialization
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top