2016-10-26 12 views
0

選択したイメージの下にテキストボックスを挿入してインラインテキストラップを挿入し、イメージの左下に配置しようとしています。私は多くの成功なしで以下のコードを使用しています。私はShapeRangeかInlineShapeのどちらを使用するかはあまりよく分かりません。すべてのポインタ?VBAを使用してMS Word上のインラインシェイプの下にテキストボックスを追加

Dim shp As Object 
'Set shp = Selection.ShapeRange(1) 
'Set rng = shp.Anchor 
Set shp = Selection.InlineShapes(1) 
Set rng = shp.Range 

With ActiveDocument.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, Left:=shp.Left, Top:=(shp.Top + shp.Height), Width:=shp.Width/3, Height:=shp.Height/6, Anchor:=rng) 
    .TextFrame.TextRange.Font.Size = 14 
    .TextFrame.TextRange.Font.Color = RGB(186, 14, 29) 
    .TextFrame.TextRange.Font.Name = "Sabon MT" 
    .TextFrame.TextRange = "T" 
End With 

答えて

0

私はここから形状の座標を取得するための解決策を見つけるために管理:http://www.vbaexpress.com/forum/archive/index.php/t-48831.html

は、ここに私のコードです:

Sub AddTextBox 

    Set shp = Selection.InlineShapes(1) 
    Set rng = shp.Range  
    Set tb = ActiveDocument.Shapes.AddTextbox(1, fcnXCoord, fcnYCoord + shp.Height, shp.Width, shp.Height/6) 

End Sub 

Function fcnXCoord() As Double 
    fcnXCoord = Selection.Information(wdHorizontalPositionRelativeToPage) 
End Function 

Function fcnYCoord() As Double 
    fcnYCoord = Selection.Information(wdVerticalPositionRelativeToPage) 
End Function 
関連する問題