UIObject.ToolbarSets 属性 (Visio)

返回 UIObject 对象的 ToolbarSets 集合。 此为只读属性。

语法

expressionToolbarSets

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

返回值

ToolbarSets

备注

注意

从 Visio 2010 开始,Microsoft Office Fluent 用户界面 (UI) 替换了以前的分层菜单、工具栏和任务窗格系统。 用于在以前版本的 Visio 中自定义用户界面的 VBA 对象和成员在 Visio 中仍可用,但它们的功能不同。

如果 UIObject 对象代表工具栏(例如,如果该对象是使用 Application 对象的 BuiltInToolbars 属性进行检索的),则它的 ToolbarSets 集合代表该 UIObject 对象的所有工具栏。

使用 ToolbarSets 对象的 ItemAtID 属性可检索特定窗口上下文的工具栏,例如绘图窗口。 如果上下文不包括工具栏,则它没有 ToolbarSets 集合。

示例

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

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

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

 
Public Sub ToolbarSets_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 支持和反馈,获取有关如何接收支持和提供反馈的指南。