図形を挿入した後、 を使用し.RelativeVerticalPosition
て図形を配置できます。この例を参照してください
Sub Sample()
Dim objShape As Shape
Set objShape = ActiveDocument.Shapes.AddTextbox _
(Orientation:=msoTextOrientationHorizontal, _
Left:=10, Top:=10, Width:=80, Height:=80)
With objShape
.RelativeHorizontalPosition = wdRelativeHorizontalPositionColumn
.RelativeVerticalPosition = wdRelativeVerticalPositionBottomMarginArea
.Left = wdShapeCenter
.Top = wdShapeTop
End With
End Sub
ファローアップ
もう 1 つの方法は、カーソル位置を見つけて、その位置に図形を挿入することです。たとえば、これはカーソルがある場所に形状を挿入します。したがって、元の VBA コードでは、 を使用Selection.TypeParagraph
して次の行に移動し、以下のコードを呼び出すことができます。
Sub Sample()
Dim objShape As Shape
Dim pos, PtsToInches
Set objShape = ActiveDocument.Shapes.AddTextbox _
(Orientation:=msoTextOrientationHorizontal, _
Left:=10, Top:=10, Width:=80, Height:=80)
pos = Selection.Information(wdVerticalPositionRelativeToPage)
PtsToInches = pos / 72
With objShape
.RelativeHorizontalPosition = wdRelativeHorizontalPositionColumn
.Left = wdShapeCenter
.Top = PtsToInches
End With
End Sub