Toolbar.ToolbarItems 属性 (Visio)

返回 Toolbar 对象的 ToolbarItems 集合。 此为只读属性。

语法

expressionToolbarItems

表达 一个代表 Toolbar 对象的变量。

返回值

ToolbarItems

示例

以下 Microsoft Visual Basic for Applications (VBA) 宏显示如何使用 ToolbarItems 属性获取集合中的特定对象。 该宏还显示如何获取内置 Visio 工具栏的副本、添加工具栏按钮、设置按钮图标,以及使用自定义工具栏集替换内置工具栏集。

在运行此代码之前,请将 替换为 path\filename 计算机上有效图标 (.ico) 文件的完整路径和名称。

运行此宏后,要恢复内置 Visio 工具栏,请调用 ThisDocument.ClearCustomToolbars 方法。

 
Public Sub ToolbarItems_Example() 
 
 Dim vsoUIObject As Visio.UIObject 
 Dim vsoToolbarSet As Visio.ToolbarSet 
 Dim vsoToolbarItems As Visio.ToolbarItems 
 Dim vsoToolbarItem As Visio.ToolbarItem 
 
 'Get the UIObject object for the copy of the built-in toolbars. 
 Set vsoUIObject = Visio.Application.BuiltInToolbars(0) 
 
 'Get the drawing window toolbar sets. 
 'NOTE: Use ItemAtID to get the toolbar set. 
 'Using vsoUIObject.ToolbarSets(visUIObjSetDrawing) will not work. 
 Set vsoToolbarSet = vsoUIObject.ToolbarSets.ItemAtID(visUIObjSetDrawing) 
 
 'Get the ToolbarItems collection. 
 Set vsoToolbarItems = vsoToolbarSet.Toolbars(0).ToolbarItems 
 
 'Add a new button in the first position. 
 Set vsoToolbarItem = vsoToolbarItems.AddAt(0) 
 
 'Set properties for the new toolbar button. 
 vsoToolbarItem.CntrlType = visCtrlTypeBUTTON 
 vsoToolbarItem.CmdNum = visCmdPanZoom 
 
 'Set the toolbar button icon. 
 vsoToolbarItem.IconFileName "path\filename" 
 
 'Use the new custom UI. 
 ThisDocument.SetCustomToolbars vsoUIObject 
 
End Sub

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。