Distribute 方法

       

在指定的形状范围内均匀分布形状。可以指定是水平还是垂直分布形状,以及是在整个幻灯片中还是在它们原来所在的空间内分布形状。

expression.Distribute(DistributeCmd, RelativeTo)

expression  必选。该表达式返回一个 ShapeRange 对象。

DistributeCmd  必选。MsoDistributeCmd 类型。指定在该范围内的形状是水平分布还是垂直分布。

RelativeTo  必选。MsoTriState 类型。决定形状在幻灯片的整个水平或垂直空间上是否均匀分布。

示例

本示例定义包含在 myDocument 上的所有自选图形的形状范围,然后在该范围内水平分布这些形状。

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.Distribute msoDistributeHorizontally, msoFalse
        End If
    End If
End With