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

Selection.Distribute Method (Visio)

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

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

NameRequired/OptionalData TypeDescription
DistributeRequiredVisDistributeTypesSpecifies how the shapes are distributed. See Remarks for possible values.
GlueToGuideOptionalBooleanIf 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.

ConstantValueDescription
visDistHorzCenter2Distributes shapes horizontally so that their bottom edges are uniformly spaced.
visDistHorzLeft1Distributes shapes horizontally so that their left edges are uniformly spaced.
visDistHorzRight3Distributes shapes horizontally so that their right edges are uniformly spaced.
visDistHorzSpace0Distributes shapes horizontally so that there is a uniform space between shapes.
visDistVertBottom7Distributes shapes vertically so that their bottom edges are uniformly spaced.
visDistVertMiddle6Distributes shapes vertically so that their centers are uniformly spaced.
visDistVertSpace4Distributes shapes vertically so that there is a uniform space between shapes.
visDistVertTop5Distributes 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
© 2018 Microsoft