Distribute 方法

       

在指定图形区域中平均分布图形。可选择纵向分布或横向分布,也可选择将各图形分布于整个页面还是仅限于原先占据的空间。

expression.Distribute(Distribute, RelativeTo)

expression   必需。该表达式返回“应用于”列表中的一个对象。

Distribute  MsoDistributeCmd,必需。

RelativeTo  必需,Long 类型。值为 True 表示将图形均布在整个页面的横向或者纵向空间。值为 False 表示在图形原来占有的横向或者纵向空间上分布该图形。

示例

本示例可实现的功能为:定义一个图形区域,该区域包含活动文档中所有的自选图形,再将各图形水平分布在此区域内。

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