ShapeRange.Distribute メソッド (Publisher)

指定された図形範囲の図形を等間隔に配置します。

構文

分散 (DistributeCmdRelativeTo)

ShapeRange オブジェクトを表す変数。

パラメーター

名前 必須 / オプション データ型 説明
DistributeCmd 必須 MsoDistributeCmd 図形を左右または上下のどちらに整列させるかを指定します。 Microsoft Office タイプ ライブラリで宣言されている MsoDistributeCmd クラスの定数のいずれかを指定できます。
RelativeTo 必須 MsoTriState ページ全体にわたって上下または左右に図形を等間隔に配置するか、またはそれらの図形があった元の範囲内で上下または左右に等間隔に配置するかを指定します。

注釈

図形は、図形どうしの距離が等しくなるように配置されます。 与えられた領域内で等間隔に配置したときに図形が大きすぎて重なる場合は、図形どうしの重なりの量が等しくなるように配置されます。

RelativeTo パラメーターには、Microsoft Office タイプ ライブラリで宣言されている、次の MsoTriState クラスの定数のいずれかを指定できます。

定数 説明
msoFalse 図形の範囲が最初に占める水平方向または垂直方向の空間内に図形を分散します。
msoTrue ページ上の水平方向または垂直方向のスペース全体に図形を均等に分散します。

RelativeTomsoTrue の場合、2 つの外側の図形とページの端の間の距離が 1 つの図形と次の図形の間の距離と同じになるように図形が分散されます。 図形が重なる場合は、外側の 2 つの図形がページの端に移動されます。

RelativeTomsoFalse の場合、2 つの外側の図形は移動されません。内側の図形の位置のみが調整されます。

このメソッドを呼び出しても図形の 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 のサポートおよびフィードバックを参照してください。