Copy Method

Microsoft Office Visual Basic

Copies a command bar control to an existing command bar.

expression.Copy(Bar, Before)

expression    Required. An expression that returns a CommandBarControl, CommandBarButton, CommandBarPopup, or CommandBarComboBox object.

Bar    Optional Variant. A CommandBar object that represents the destination command bar. If this argument is omitted, the control is copied to the command bar where the control already exists.

Before    Optional Variant. A number that indicates the position for the new control on the command bar. The new control will be inserted before the control at this position. If this argument is omitted, the control is copied to the end of the command bar.

Example

This example copies the first control from the command bar named "Standard" to the first control on the command bar named "Custom”.

Set myCustomBar = CommandBars("Custom")
Set myControl = CommandBars("Standard").Controls(1)
With myControl
    .Copy Bar:=myCustomBar, Before:=1
    .SetFocus
End With