共用方式為


Application.BuiltInToolbars property (Visio)

回傳一個 UIObject 物件,代表 Microsoft 內建工具列的副本。 唯讀。

注意事項

自 Visio 2010 起,Microsoft Office Fluent 使用者介面 (介面) 取代了先前分層選單、工具列與工作窗格的系統。 你在先前版本 Visio 中用來自訂使用者介面的 VBA 物件和成員仍然可以在 Visio 中使用,但它們的運作方式不同。

語法

表情BuiltInToolbars (fIgnored)

expression 代表 Application 物件的變數。

參數

名稱 必要/選用 資料類型 描述
fIgnored(忽略) 必要 整數 回溯相容性需要用到它,但是予以略過。 建議您傳遞零 (0) 的值。

傳回值

UIObject

註解

使用 BuiltInToolbars 屬性取得 UIObject 物件並修改其工具列。 接著你可以使用 ApplicationDocument 物件的 SetCustomToolbars 方法,將自訂的工具列替換成內建的 Visio 工具列。

還可以使用 UIObject 物件的 SaveToFile 方法將其工具列儲存到檔案中,然後再設定 ApplicationDocument 物件的 CustomToolbarsFile 屬性,將這些工具列重新載入為自訂的工具列。

在 Visio 5.0 之前,支持此特性的理由是 fWhichToolbars,該工具列指定了 MSOffice 或 LotusSS) (的工具列類型。 從 Visio 5.0 開始,應用程式不再支援不同類型的工具列,目前的參數 fIgnored 也被忽略。

範例

這個 Microsoft Visual Basic for Applications (VBA) 巨集會示範如何使用 BuiltInToolbars 屬性來取得 Visio 內建工具列的複本、加入工具列按鈕、設定按鈕圖示,以及以自訂的組合取代內建的工具列組合。

在執行此巨集前,請在以下程式碼中替換 (path\filename) 成你電腦上 (.ico) 圖示檔案的完整路徑及檔案名稱。

若要在執行這個巨集之後還原 Visio 內建工具列,請呼叫 ThisDocument.ClearCustomToolbars 方法。

 
Public Sub BuiltInToolbars_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 sets.'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 
 
 'Set the caption for the new toolbar button. 
 vsoToolbarItem.Caption = "MyButton" 
 
 'Set the icon for the new toolbar button. 
 vsoToolbarItem.IconFileName "(path\filename)" 'Tell Visio to actually use the new custom UI. 
 ThisDocument.SetCustomToolbars vsoUIObject 
 
End Sub

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應