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

ShapeRange.Distribute Method (PowerPoint)

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

Evenly distributes the shapes in the specified range of shapes. You can specify whether you want to distribute the shapes horizontally or vertically and whether you want to distribute them over the entire slide or just over the space they originally occupy.


expression. Distribute( DistributeCmd, RelativeTo )

expression A variable that represents a ShapeRange object.


NameRequired/OptionalData TypeDescription
DistributeCmdRequiredMsoDistributeCmdSpecifies whether shapes in the range are to be distributed horizontally or vertically.
RelativeToRequiredMsoTriStateDetermines whether shapes are distributed evenly over the entire horizontal or vertical space on the slide.

Return Value



This example defines a shape range that contains all the AutoShapes on the myDocument and then horizontally distributes the shapes in this range.

Set myDocument = ActivePresentation.Slides(1) 
With myDocument.Shapes 
    numShapes = .Count 
    If numShapes > 1 Then 
        numAutoShapes = 0 
        ReDim autoShpArray(1 To numShapes) 
        For i = 1 To numShapes 
            If .Item(i).Type = msoAutoShape Then 
                numAutoShapes = numAutoShapes + 1 
                autoShpArray(numAutoShapes) = .Item(i).Name 
            End If 
        If numAutoShapes > 1 Then 
            ReDim Preserve autoShpArray(1 To numAutoShapes) 
            Set asRange = .Range(autoShpArray) 
            asRange.Distribute msoDistributeHorizontally, msoFalse 
        End If 
    End If 
End With

See also


ShapeRange Object

© 2018 Microsoft