Toolbar.Top Property (Visio)

Gets the distance between the top of an object and the top of the docking area or the top of the screen if the object isn't docked; it sets the distance between the top of a Toolbar object and the top of the screen. Read/write.


expression. Top

expression A variable that represents a Toolbar object.

Return value



This example shows how to use the Top property to set the position of a UIObject object. The example adds a custom toolbar to the cloned toolbars collection. This toolbar appears in the Microsoft Visio user interface and is available while the document is active.

To restore Visio's built-in toolbars after you run this macro, call the ThisDocument.ClearCustomToolbars method.

Public Sub Top_Example() 
 Dim vsoUIObject As Visio.UIObject 
 Dim vsoToolbars As Visio.Toolbars 
 Dim vsoToolbar As Visio.Toolbar 
 'Check whether there are document custom toolbars. 
 If ThisDocument.CustomToolbars Is Nothing Then 
 'If not, check whether there are application custom toolbars. 
 If Visio.Application.CustomToolbars Is Nothing Then 
 'If not, use the built-in toolbars. 
 Set vsoUIObject = Visio.Application.BuiltInToolbars(0) 
 'If there are application custom toolbars, clone them. 
 Set vsoUIObject = Visio.Application.CustomToolbars.Clone 
 End If 
 'If there are custom toolbars in the document, use them. 
 Set vsoUIObject = ThisDocument.CustomToolbars 
 End If 
 'Get the Toolbars collection for the drawing window context. 
 Set vsoToolbars = vsoUIObject.ToolbarSets.ItemAtID( _ 
 'Add a toolbar to the collection. 
 Set vsoToolbar = vsoToolbars.Add 
 With vsoToolbar 
 'Set the title of the toolbar. 
 .Caption = "My New Toolbar" 
 'Float the toolbar at coordinates (300,200). 
 .Position = Visio.visBarFloating 
 .Left = 300 
 .Top = 200 
 End With 
 'Use the custom toolbars in this document. 
 ThisDocument.SetCustomToolbars vsoUIObject 
End Sub