显示userform后,将焦点设置回应用程序窗口 [英] Set focus back to the application window after showing userform

查看:106
本文介绍了显示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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆