Skip to main content

CommandBars.ActiveMenuBar property

Table of contents
  1. Syntax
  2. Example

Gets a CommandBar object that represents the active menu bar in the container application. Read-only.



expression A variable that represents a CommandBars object.


This example adds a temporary pop-up control named Custom to the end of the active menu bar, and adds a control named Import to the popup control.

Set myMenuBar = CommandBars.ActiveMenuBar 
Set newMenu = myMenuBar.Controls.Add(Type:=msoControlPopup, Temporary:=True) 
newMenu.Caption = "Custom" 
Set ctrl1 = newMenu.CommandBar.Controls _ 
    .Add(Type:=msoControlButton, Id:=1) 
With ctrl1 
    .Caption = "Import" 
    .TooltipText = "Import" 
    .Style = msoButtonCaption 
End With

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>