Selection.Distribute method (Visio)
Distributes three or more selected shapes at regular intervals on the drawing page. The order of selection is irrelevant.
Syntax
expression. Distribute
( _Distribute_
, _GlueToGuide_
)
expression A variable that represents a Selection object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
Distribute | Required | VisDistributeTypes | Specifies how the shapes are distributed. See Remarks for possible values. |
GlueToGuide | Optional | Boolean | If True, creates guides and glues selected shapes to them. If False, does not. Default is False. |
Return value
Nothing
Remarks
The following possible values for Distribute are declared in VisDistributeTypes in the Visio type library.
Constant | Value | Description |
---|---|---|
visDistHorzCenter | 2 | Distributes shapes horizontally so that their bottom edges are uniformly spaced. |
visDistHorzLeft | 1 | Distributes shapes horizontally so that their left edges are uniformly spaced. |
visDistHorzRight | 3 | Distributes shapes horizontally so that their right edges are uniformly spaced. |
visDistHorzSpace | 0 | Distributes shapes horizontally so that there is a uniform space between shapes. |
visDistVertBottom | 7 | Distributes shapes vertically so that their bottom edges are uniformly spaced. |
visDistVertMiddle | 6 | Distributes shapes vertically so that their centers are uniformly spaced. |
visDistVertSpace | 4 | Distributes shapes vertically so that there is a uniform space between shapes. |
visDistVertTop | 5 | Distributes shapes vertically so that their top edges are uniformly spaced. |
Calling the Distribute method is equivalent to setting options in the Distribute Shapes dialog box (on the Home tab, click Position, point to Space Shapes, and then click More Distribute Options).
Passing True for the optional GlueToGuide argument is the equivalent of selecting the Create guides and glue shapes to them check box in the Distribute Shapes dialog box.
When you pass True for GlueToGuide, Visio creates guides to retain the distribution of the shapes. You can select and move the outermost guides to move the shapes without changing their distribution.
Example
This Microsoft Visual Basic for Applications (VBA) macro shows how to use the Distribute method to distribute three shapes vertically so that their right edges are uniformally spaced and glued to guides.
Public Sub Distribute_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.DeselectAll
ActiveWindow.Select vsoShape1, visSelect
ActiveWindow.Select vsoShape2, visSelect
ActiveWindow.Select vsoShape3, visSelect
Application.ActiveWindow.Selection.Distribute visDistVertRight, True
End Sub
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.