ShapeRange.Distribute Method
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.
Namespace: Microsoft.Office.Interop.PowerPoint
Assembly: Microsoft.Office.Interop.PowerPoint (in Microsoft.Office.Interop.PowerPoint.dll)
Syntax
'Declaration
Sub Distribute ( _
DistributeCmd As MsoDistributeCmd, _
RelativeTo As MsoTriState _
)
'Usage
Dim instance As ShapeRange
Dim DistributeCmd As MsoDistributeCmd
Dim RelativeTo As MsoTriState
instance.Distribute(DistributeCmd, RelativeTo)
void Distribute(
MsoDistributeCmd DistributeCmd,
MsoTriState RelativeTo
)
Parameters
- DistributeCmd
Type: Microsoft.Office.Core.MsoDistributeCmd
Specifies whether shapes in the range are to be distributed horizontally or vertically.
- RelativeTo
Type: Microsoft.Office.Core.MsoTriState
Determines whether shapes are distributed evenly over the entire horizontal or vertical space on the slide.
Examples
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
Next
If numAutoShapes > 1 Then
ReDim Preserve autoShpArray(1 To numAutoShapes)
Set asRange = .Range(autoShpArray)
asRange.DistributemsoDistributeHorizontally, msoFalse
End If
End If
End With