FindControls Method Example

This example uses the FindControls method to return all members of the CommandBarControls collection that have an ID of 18 and displays (in a message box) the number of controls that meet the search criteria.

Dim myControls As CommandBarControls
Set myControls = CommandBars.FindControls(Type:=msoControlButton, ID:=18)
MsgBox "There are " & myControls.Count & _
    " controls that meet the search criteria."