FindControl Method Example

This example finds the first control on the command bar named “Custom”. If the control is a button, the example uses the FindControl method to find the Copy button (on the Standard toolbar) and then copies the face from the Copy button and pastes it onto the control.

Set oldCtrl = CommandBars("Custom").Controls(1)
If oldCtrl.Type = 1 Then
    Set newCtrl = CommandBars.FindControl(Type:= _
        MsoControlButton, ID:= _
        CommandBars("Standard").Controls("Copy").ID)
    NewCtrl.CopyFace
    OldCtrl.PasteFace
End If