Table of contents
Collapse the table of content
Expand the table of content

Selection.Align Method (Visio)

office 365 dev account|Last Updated: 6/12/2017
1 Contributor

Aligns two or more selected shapes.


expression . Align( AlignHorizontal , AlignVertical , GlueToGuide )

expression A variable that represents a Selection object.


NameRequired/OptionalData TypeDescription
AlignHorizontalRequiredVisHorizontalAlignTypesAligns selected shapes along a horizontal axis. See Remarks for possible values.
AlignVerticalRequiredVisVerticalAlignTypesAligns selected shapes along a vertical axis. See Remarks for possible values.
GlueToGuideOptionalBooleanIf True , creates a guide and glues selected shapes to it; if False , it does not. The default is False .

Return Value



The following possible values for AlignHorizontal are declared in VisHorizontalSelectionTypes in the Visio type library.

** Constant**** Value**** Description**
visHorzAlignCenter2Aligns to the center of the primary selected shape.
visHorzAlignLeft1Aligns to the left of the primary selected shape.
visHorzAlignNone0Does not align horizontally.
visHorzAlignRight3Aligns to the right of the primary selected shape.

The following possible values for AlignVertical are declared in VisVerticalSelectionTypes in the Visio type library.

** Constant**** Value**** Description**
visVertAlignBottom3Aligns to bottom of primary selected shape.
visVertAlignMiddle2Aligns to middle of primary selected shape.
visVertAlignNone0Does not align vertically.
visVertAlignTop1Aligns to top of primary selected shape.

If you pass non-zero values for both AlignHorizontal and AlignVertical, the selected shapes appear superimposed. The most recently created shape appears at the front of the z-order.

Calling the Align method is equivalent to clicking Position on the Home tab and then setting options under Align Shapes.


This Microsoft Visual Basic for Applications (VBA) macro shows how to use the Align method to align three shapes vertically.

Public Sub Align_Example() 

    Dim vsoShape1 As Visio.Shape 
    Dim vsoShape2 As Visio.Shape 
    Dim vsoShape3 As Visio.Shape 

    Set vsoShape1 = Application.ActiveWindow.Page.DrawRectangle(1, 9, 3, 7) 
    Set vsoShape2 = Application.ActiveWindow.Page.DrawRectangle(3, 6, 5, 5) 
    Set vsoShape3 = Application.ActiveWindow.Page.DrawRectangle(6, 4, 8, 2) 


    ActiveWindow.Select vsoShape1, visSelect 
    ActiveWindow.Select vsoShape2, visSelect 
    ActiveWindow.Select vsoShape3, visSelect 

    Application.ActiveWindow.Selection.Align visHorzAlignRight, visVertAlignNone, False 

End Sub
© 2018 Microsoft