获取符合指定条件的 CommandBarControls 集合。
注意
某些 Microsoft Office 应用程序中对 CommandBars 的使用已由 Microsoft Office Fluent 用户界面的新功能区组件取代。 有关详细信息,请参阅 Office Fluent 功能区概述。
语法
表达式。FindControls (Type、 Id、 Tag、 Visible)
表达 一个代表 CommandBars 对象的变量。
参数
名称 | 必需/可选 | 数据类型 | 说明 |
---|---|---|---|
Type | 可选 | Variant | 指定控件类型的 MsoControlType 常量之一。 |
Id | 可选 | Variant | 控件的标识符。 |
Tag | 可选 | Variant | 控件的 标记值。 |
Visible | 可选 | Variant | 如果为 True ,则仅在搜索中包含可见的命令栏控件。 默认值为 False。 |
返回值
CommandBarControls
备注
如果未找到符合条件的控件, FindControls 方法将返回 Nothing。
示例
此示例使用 FindControls 方法返回 ID 为 18 的 CommandBars 集合的所有成员,并在消息框中显示 () 满足搜索条件的控件数。
Dim myControls As CommandBarControls
Set myControls = CommandBars.FindControls(Type:=msoControlButton, ID:=18)
MsgBox "There are " & myControls.Count & _
" controls that meet the search criteria."
另请参阅
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。