Excel MenuBar Commands and List of IDs

Excel MenuBar Commands and List of IDs

MenuBar

Collection of commands available on each Ribbon. Each menu or command has a unique identity which is known as command ID. With the help of command id a developer can manipulate menubar. Manipulating menus in this way known as customization. Let’s see some commands and their ids. List of menubar commands can be downloaded from here. There are many objects, methods and properties which makes commandbar programming robust in nature.

Code example

Public Sub MenuBar()
    'Declare variable for commands
    Dim oCommands As CommandBars
    'Get all command bars
    Set oCommands = Application.CommandBars
    'Declare single command bar
    Dim command As CommandBar
    'Set 1st command bar
    Set command = oCommands(1)
    'Declare control
    Dim ctrl As CommandBarControl
    'Get View menu
    Set ctrl = command.FindControl(, 30004)
    
    'do here whatever you wish with ctrl as you got complete object in hand

End Sub

Please leave your comments or queries under comment section also please do subscribe to out blogs to keep your self upto date.

Next>>Executing Macro from External File Using Excel VBA

Leave a Reply

Your email address will not be published.