共用方式為


ShapeRange.Distribute 方法 (Excel)

在指定的圖案範圍中水平或垂直分散對齊圖案。

語法

運算式Distribute (DistributeCmdRelativeTo)

表達 代表 ShapeRange 物件的 變數。

參數

名稱 必要/選用 資料類型 描述
DistributeCmd 必要 MsoDistributeCmd 指定要水平還是垂直分配範圍中的圖案。
RelativeTo 必要 MsoTriState 不在 Microsoft Excel 中使用。 必須為 False

範例

本範例會在 myDocument 上定義包含所有快取圖案的圖案範圍,然後水平分散對齊該範圍中的圖案。 最左邊的圖案將留在原位。

Set myDocument = Worksheets(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, False 
        End If 
    End If 
End With

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應