Invalid VBA form stops function keys

I would like to have my help file in my Excel program.

IN

Private Sub Workbook_Open() 

I have

 Application.OnKey "{F1}", "Help" 

This works when I am on an Excel worksheet, but my application is based on a full-screen main user format that displays modelessly.

When the user form is visible, it somehow locks the F1 key, and the macro does not start.

I thought that weak forms did not block code execution.

Any clues how can I do this?

+5
source share
1 answer

You need to capture the keyDown event in the user form itself. When a UserForm gets focus, anyone you click goes into 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 
+5
source

Source: https://habr.com/ru/post/1263103/


All Articles