Share via


Top Property [Visio 2003 SDK Documentation]

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 Menu or Toolbar object and the top of the screen.

intRet = object**.Top**

object**.Top** = intExpression

intRet     Integer. The distance in pixels.

object     Required. An expression that returns a MenuSet or Toolbar object.

intExpression     Required Integer. The new distance in pixels.

Version added

2000

Example

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 Office 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) 

        Else

            'If there are application custom toolbars, clone them. 
            Set vsoUIObject = Visio.Application.CustomToolbars.Clone
 
        End If  

    Else

        '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( _ 
        Visio.visUIObjSetDrawing).Toolbars 

    '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

Applies to | MenuSet object | Toolbar object

See Also | Height property | Position property | Width property