显示userform后,将焦点设置回应用程序窗口 [英] Set focus back to the application window after showing userform
问题描述
当显示一个用户窗体(运行其显示
方法)时,它不仅显示在屏幕上,而且还会显示焦点(例如按键的目的地)。
When showing a userform (running its Show
method) it not only shows up on the screen but also takes the focus (the destination of e.g. keystrokes).
说,userform是一个自定义的工具栏。其显示
在 Workbook_Open()
中触发,但表单本身相对较少使用,因此我们希望焦点返回主要应用程序窗口出现后。
Say, the userform is a custom made toolbar. Its Show
fires in Workbook_Open()
but the form itself is used relatively rarely so we want the focus to go back to the main application window right after its appearance.
不幸的是,似乎 SetFocus
方法无效应用程序对象
Unfortunately, it seems SetFocus
method is not valid for application objects.
那么这样做如何?
来自
Private Sub Workbook_Open()
[...]
UserForm1.Show
推荐答案
我使用这个:
AppActivate Application.caption
这将重点从用户窗体重设为Excel Sheet。
this resets the focus from a userform to your Excel Sheet.
这篇关于显示userform后,将焦点设置回应用程序窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!