-
Calling Function Keys
I have been trying to trap the F1 function key - I have tried two methods - see code below - But I cannot trap the F1 key or the TAB key(using TAB here just so they are different calls) - My code is called from a UserForm (when it is activated) - wondering if that is why it is not working
Code:
Private Sub DemoOnKey()
Application.OnKey "{TAB}", "Message"
End Sub
Private Sub Message()
Call ReadHelpFile(Language)
End Sub
Private Sub UserForm_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case vbKeyF1
Call ReadHelpFile(Language)
End Select
End Sub
-
Hi,
Test in this way:
Code:
Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = vbKeyF1 Then
'your code here
MsgBox "Hallo!"
End If
End Sub