共用方式為


ShapeRange.Distribute 方法 (Publisher)

停均分配圖案到指定的圖案範圍。

語法

運算式Distribute (DistributeCmdRelativeTo)

表達 代表 ShapeRange 物件的 變數。

參數

名稱 必要/選用 資料類型 描述
DistributeCmd 必要 MsoDistributeCmd 指定圖案是水平分配或垂直分配。 可以是 Microsoft Office 類型程式庫中所宣告的 MsoDistributeCmd 常數之一。
RelativeTo 必要 MsoTriState 指定是否將圖案平均分配到頁面上整個的水平或垂直空間,或是圖案原來佔有的水平或垂直範圍內。

註解

分配圖案以使圖案與圖案之間的空間是平均的。 如果圖案太大以致於分配在可用空間時重疊,分配圖案可以讓圖案間的重疊量平均。

RelativeTo參數可以是 Microsoft Office 類型程式庫中所宣告的MsoTriState常數之一,如下表所示。

常數 描述
msoFalse 在圖形範圍原本佔用的水準或垂直空間內散發圖形。
msoTrue 將圖形平均分配到頁面上的整個水準或垂直空間。

RelativeTomsoTrue時,會分散圖形,讓兩個外部圖形與頁面邊緣之間的距離與一個圖形與下一個圖案之間的距離相同。 如果圖形必須重疊,兩個外部圖形會移至 [] 頁面上緣。

RelativeTomsoFalse 時,不會移動兩個外部圖形;只會調整內部圖形的位置。

圖案的 Z 順序不會受此方法影響。

範例

本範例會定義包含使用中出版物第一頁上所有快取圖案的圖案範圍,然後水準散發此範圍中的圖案。

' Number of shapes on the page. 
Dim intShapes As Integer 
' Number of AutoShapes on the page. 
Dim intAutoShapes As Integer 
' An array of the names of the AutoShapes. 
Dim arrAutoShapes() As String 
' A looping variable. 
Dim shpLoop As Shape 
' A placeholder variable for the range containing AutoShapes. 
Dim shpRange As ShapeRange 
 
With ActiveDocument.Pages(1).Shapes 
 ' Count all the shapes on the page. 
 intShapes = .Count 
 
 ' Proceed only if there's at least one shape. 
 If intShapes > 1 Then 
 intAutoShapes = 0 
 ReDim arrAutoShapes(1 To intShapes) 
 
 ' Loop through the shapes on the page and add the names 
 ' of any AutoShapes to an array. 
 For Each shpLoop In ActiveDocument.Pages(1).Shapes 
 If shpLoop.Type = msoAutoShape Then 
 intAutoShapes = intAutoShapes + 1 
 arrAutoShapes(intAutoShapes) = shpLoop.Name 
 End If 
 Next shpLoop 
 
 ' Proceed only if there's at least one AutoShape. 
 If intAutoShapes > 1 Then 
 ReDim Preserve arrAutoShapes(1 To intAutoShapes) 
 
 ' Create a shape range containing all the AutoShapes. 
 Set shpRange = .Range(Index:=arrAutoShapes) 
 
 ' Distribute the AutoShapes horizontally 
 ' in the space they already occupy. 
 shpRange.Distribute _ 
 DistributeCmd:=msoDistributeHorizontally, RelativeTo:=msoFalse 
 End If 
 End If 
End With 

支援和意見反應

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