Skip to main content

CommandBars.ReleaseFocus method

Table of contents
  1. Syntax
  2. Example

Releases the user interface focus from all command bars.



expression A variable that represents a CommandBars object.


This example adds three blank buttons to the command bar named Custom and sets the focus to the center button. The example then waits five seconds before releasing the user interface focus from all command bars.

Sub Macro1()
    Set myBar = CommandBars _
        .Add(Name:="Custom1", Position:=msoBarTop, _
    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
    End With
    PauseTime = 5   ' Set duration.
        Start = Timer   ' Set start time.
        Do While Timer = Start + PauseTime
            DoEvents    ' Yield to other processes.
        Finish = Timer
End Sub

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>