Visio2000: How to Dock a Built-in or Custom Toolbar (272715)



The information in this article applies to:

  • Microsoft Visio Professional 5.0
  • Microsoft Visio 2000 Standard Edition
  • Microsoft Visio 2000 Professional Edition
  • Microsoft Visio 2000 Technical Edition
  • Microsoft Visio 2000 Enterprise Edition

This article was previously published under Q272715

SUMMARY

This article contains a sample Microsoft Visual Basic for Applications macro (Sub procedure) to dock (move) a specified active toolbar to the top, left or to float it in the active document window.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. The following sample Visual Basic macro searches for the specified built-in or custom toolbar (BuiltInToolbars) and docks (moves) it to the top, left or floats it in the active document window.

NOTE: In order to make this sample macro work, please replace the placeholder 'toolbar' in the code with the name of the toolbar that you want to use.

Public Sub MoveWebToolbarToTop()
    ' Creates new toolbar docked at top of frame
    MoveToolbar "'toolbar'", visBarTop
End Sub
 
Public Sub MoveWebToolbarToLeft()
    ' Creates new toolbar docked at left of frame
    MoveToolbar "'toolbar'", visBarLeft
End Sub
 
Public Sub MakeWebToolbarFloating()
    ' Creates new floating toolbar
    MoveToolbar "'toolbar'", visBarFloating
End Sub
 
Private Sub MoveToolbar(toolbarcaption As String, position As VisUIBarPosition)
    Dim uiObj As UIObject
    Dim toolbarsObj As Toolbars
    Dim toolbarObj As Toolbar
     
    Set uiObj = Visio.Application.BuiltInToolbars(0)
    Set toolbarsObj= uiObj.ToolbarSets.ItemAtID(Visio.visUIObjSetDrawing).Toolbars
    For i = 0 To toolbarsObj.Count - 1
        If toolbarsObj(i).Caption = toolbarcaption Then
            toolbarsObj(i).position = position
            Exit For
        End If
    Next
    ThisDocument.SetCustomToolbars uiObj
 End Sub
				

Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbdtacode kbhowto kbmacro KB272715