Distribute Method
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
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 page or just over the space they originally occupy.
expression.Distribute(Distribute, RelativeTo)
expression Required. An expression that returns one of the objects in the Applies To list.
MsoDistributeCmd
MsoDistributeCmd can be one of these MsoDistributeCmd constants. |
msoDistributeHorizontally |
msoDistributeVertically |
RelativeTo Required Long. True to distribute the shapes evenly over the entire horizontal or vertical space on the page. False to distribute them within the horizontal or vertical space that the range of shapes originally occupies.
Example
This example defines a shape range that contains all the AutoShapes on the active document and then horizontally distributes the shapes in this range.
With ActiveDocument.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.Distribute msoDistributeHorizontally, False
End If
End If
End With