Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在我的 Excel 程序中有我自己的帮助文件。
在里面
Private Sub Workbook_Open()
我有
Application.OnKey "{F1}", "Help"
当我在 Excel 工作表上但我的应用程序基于无模式显示的全屏主用户窗体时,这有效。
当用户窗体可见时,它会F1以某种方式阻止键并且宏不会触发。
我认为无模式表单不会阻止代码执行。
任何提示我怎样才能使这项工作?
您需要keyDown在用户窗体本身上捕获事件。当用户窗体获得焦点时,您按下的任何键都会转到用户窗体。
keyDown
'/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