目录

ReleaseFocus 方法

优质
小牛编辑
129浏览
2023-12-01

全部显示

释放所有命令栏中用户界面的焦点。

expression.ReleaseFocus

expression 必需。该表达式返回一个CommandBars 对象。

示例

本示例可实现的功能为:向命令栏“Custom”中添加三个空白按钮,并将焦点设置在中间的按钮上。等待五秒钟后,释放所有命令栏的用户界面焦点。

Set myBar = CommandBars _
 .Add(Name:="Custom", Position:=msoBarTop, _
 Temporary:=True)
With myBar
 .Controls.Add Type:=msoControlButton
 .Controls.Add Type:=msoControlButton
 .Controls.Add Type:=msoControlButton
 .Visible = True
End With
Set myControl = CommandBars("Custom").Controls(2)
With myControl
 .SetFocus
End With
PauseTime = 5 ' Set duration.
 Start = Timer ' Set start time.
 Do While Timer < Start + PauseTime
 DoEvents ' Yield to other processes.
 Loop
 Finish = Timer
CommandBars.ReleaseFocus