FindControls Method

Microsoft Office Visual Basic

Returns the CommandBarControls collection that fits the specified criteria.

expression.FindControls(Type, Id, Tag, Visible)

expression    Required. An expression that returns a CommandBarControls collection.

Type    Optional MsoControlType. The type of control.

MsoControlType type can be one of these MsoControlType constants.
msoControlActiveX
msoControlAutoCompleteCombo
msoControlButton
msoControlButtonDropdown
msoControlButtonPopup
msoControlComboBox
msoControlCustom
msoControlDropdown
msoControlEdit
msoControlExpandingGrid
msoControlGauge
msoControlGenericDropdown
msoControlGraphicCombo
msoControlGraphicDropdown
msoControlGraphicPopup
msoControlGrid
msoControlLabel
msoControlLabelEx
msoControlOCXDropDown
msoControlPane
msoControlPopup
msoControlSpinner
msoControlSplitButtonMRUPopup
msoControlSplitButtonPopup
msoControlSplitDropdown
msoControlSplitExpandingGrid
msoControlWorkPane

Id    Optional Variant. The control’s identifier.

Tag    Optional Variant. The control’s tag value.

Visible    Optional Variant. True to include only visible command bar controls in the search. The default value is False.

Remarks

If no controls that fits the criteria are found, the FindControls method returns Nothing.

Example

This example uses the FindControls method to return all members of the CommandBars 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."