I'd like to have my own help file in my Excel program.
In the
Private Sub Workbook_Open()
I have
Application.OnKey "{F1}", "Help"
That works when I'm on the Excel sheet but my application is based on a fullscreen main userform which is displayed modeless.
When the userform is visible it blocks the F1 key somehow and the macro doesn't fire.
I thought that modeless forms didn't block code execution.
Any hints how can I make this work?
You need to trap the keyDown
event on the UserForm itself. When the UserForm has got the focus, whatever Key you press it goes to the UserForm.
'/UserForm1 is a sample name.
Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 112 Then '/ F1
Call Help
End If
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With