Propriété ToolbarItem.Enabled (Visio)

Détermine si un objet est activé. Lecture-écriture.

Syntaxe

expression. Activé

Expression Variable qui représente un objet ToolbarItem .

Valeur renvoyée

Booléen

Remarques

Remarque

À compter de Visio 2010, l’interface utilisateur Microsoft Office Fluent a remplacé le système précédent de menus en couches, de barres d’outils et de volets Office. Les objets et membres VBA que vous avez utilisés pour personnaliser l’interface utilisateur dans les versions précédentes de Visio sont toujours disponibles dans Visio, mais ils fonctionnent différemment.

Exemple

Cet exemple indique comment utiliser la propriété Enabled pour masquer ou afficher une barre d'outils. L'exemple ajoute une barre d'outils personnalisée à la collection Toolbars. Cette barre d'outils apparaît dans l'interface utilisateur de Visio et est disponible tant que le document est actif.

Pour restaurer les barres d'outils intégrées de Visio après avoir exécuté cette macro, appelez la méthode ThisDocument.ClearCustomToolbars.

 
Sub Enabled_Example() 
 
 Dim vsoUIObject As Visio.UIObject 
 Dim vsoToolbars As Visio.Toolbars 
 Dim vsoToolbar As Visio.Toolbar 
 Dim vsoToolbarItem As Visio.ToolbarItem 
 
 'Check whether there are document custom toolbars. 
 If ThisDocument.CustomToolbars Is Nothing Then 
 
 'Check whether there are application custom toolbars. 
 If Visio.Application.CustomToolbars Is Nothing Then 
 
 'Use the built-in toolbars. 
 Set vsoUIObject = Visio.Application.BuiltInToolbars(0) 
 
 Else 
 
 'Use the application custom toolbars. 
 Set vsoUIObject = Visio.Application.CustomToolbars.Clone 
 
 End If 
 
 Else 
 
 'Use the document custom toolbars. 
 Set vsoUIObject = ThisDocument.CustomToolbars 
 
 End If 
 
 'Get the Toolbars collection for the drawing window context. 
 Set vsoToolbars = vsoUIObject.ToolbarSets.ItemAtID( _ 
 Visio.visUIObjSetDrawing).Toolbars 
 
 'Add a toolbar to the collection. 
 Set vsoToolbar = vsoToolbars.Add 
 
 'Set the title of the toolbar. 
 vsoToolbar.Caption = "Example" 
 
 'Enable hiding or showing the toolbar. 
 vsoToolbar.Enabled = True 
 
 'Show the toolbar. 
 vsoToolbar.Visible = True 
 
 'Add an item to the toolbar. 
 Set vsoToolbarItem = vsoToolbar.ToolbarItems.Add 
 With vsoToolbarItem 
 
 'Set the new item to be a button. 
 .CntrlType = Visio.visCtrlTypeBUTTON 
 
 'Set the icon of the new button. 
 .FaceID = Visio.visIconIXCUSTOM_CARDS 
 
 'Set the CmdNum property of the new button. 
 .CmdNum = 1 
 
 'Set the Width property of the new button 
 'wide enough that the toolbar name is readable. 
 .Width = 100 
 
 End With 
 
 'Tell Visio to use the new UIObject object while 
 'this document is active. 
 ThisDocument.SetCustomToolbars vsoUIObject 
 
End Sub

Assistance et commentaires

Avez-vous des questions ou des commentaires sur Office VBA ou sur cette documentation ? Consultez la rubrique concernant l’assistance pour Office VBA et l’envoi de commentaires afin d’obtenir des instructions pour recevoir une assistance et envoyer vos commentaires.