CommandBars.FindControls method (Office)
Gets the CommandBarControls collection that fits the specified criteria.
Note
The use of CommandBars in some Microsoft Office applications has been superseded by the new ribbon component of the Microsoft Office Fluent user interface. For more information, see Overview of the Office Fluent ribbon.
Syntax
expression.FindControls (Type, Id, Tag, Visible)
expression A variable that represents a CommandBars object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
Type | Optional | Variant | Is one of the MsoControlType constants specifying the type of control. |
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. |
Return value
CommandBarControls
Remarks
If no controls that fit 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."
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.