Freigeben über


CommandBarButton.Move Method

Office Developer Reference

Moves the specified CommandBarButton control to an existing command bar.

Aa432775.vs_note(en-us,office.12).gif  Note
The use of CommandBars in some Microsoft Office applications has been superseded by the new Ribbon user interface. For more information, search help for the keyword "Ribbon."

Syntax

expression.Move(Bar, Before)

expression   Required. A variable that represents a CommandBarButton object.

Parameters

Name Required/Optional Data Type Description
Bar Optional Variant A Command object that represents the destination command bar for the control. If this argument is omitted, the control is moved to the end of the command bar where the control currently resides.
Before Optional Variant A number that indicates the position for the control. The control is inserted before the control currently occupying this position. If this argument is omitted, the control is inserted on the same command bar.

Example

This example moves the first combo box control on the command bar named Custom to the position before the seventh control on that command bar. The example sets the tag to "Selection box" and assigns the control a low priority so that it will likely be dropped from the command bar if all the controls don't fit in one row.

Visual Basic for Applications
  Set allcontrols = CommandBars("Custom").Controls
For Each ctrl In allControls
    If ctrl.Type = msoControlComboBox Then
        With ctrl
            .Move Before:=7
             .Tag = "Selection box"
             .Priority = 5
         End With
         Exit For
    End If
Next

See Also