CommandBars.ExecuteMso Method (Office)

Office 2013 and later
GitHub-Mark-64px

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA documentation.

Executes the control identified by the idMso parameter.

expression .ExecuteMso(idMso)

expression An expression that returns a CommandBars object.

Parameters

Name

Required/Optional

Data Type

Description

idMso

Required

String

Identifier for the control.

This method is useful in cases where there is no object model for a particular command. Works on controls that are built-in buttons, toggleButtons and splitButtons. On failure it returns E_InvalidArg for an invalid IdMso, and E_Fail for controls that are not enabled or not visible.

The following sample executes the Copy button.

Application.CommandBars.ExecuteMso(“Copy”)
Show: