Table of contents
TOC
Collapse the table of content
Expand the table of content

CommandBarButton.Execute Method (Office)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

Runs the procedure or built-in command assigned to the specified CommandBarButton control.

Note The use of CommandBars in some Microsoft Office applications has been superseded by the new ribbon component of the Microsoft Office Fluent user interface. For more information, search Help for the keyword "ribbon."

Syntax

expression. Execute

expression Required. A variable that represents a CommandBarButton object.

Example

This Microsoft Excel example creates a command bar and then adds a built-in command bar button control to it. The button executes the Excel AutoSum function. This example uses the Execute method to total the selected range of cells when the command bar appears.

Dim cbrCustBar As CommandBar 
Dim ctlAutoSum As CommandBarButton 
Set cbrCustBar = CommandBars.Add("Custom") 
Set ctlAutoSum = cbrCustBar.Controls _ 
    .Add(msoControlButton, CommandBars("Standard") _ 
    .Controls("AutoSum").Id) 
cbrCustBar.Visible = True  
ctlAutoSum.Execute

See also

Concepts

CommandBarButton Object

Other resources

CommandBarButton Object Members

© 2017 Microsoft