How to insert text into TextBox in Word Macro

2019-05-13 13:05发布

I created a text bo in the Word and I would like to insert text into it:

Sub k()
Dim Box As Shape
Set Box = ActiveDocument.Shapes.AddTextbox( _
Orientation:=msoTextOrientationHorizontal, _
Left:=50, Top:=50, Width:=100, Height:=100)
//HOW TO INSERT HERE TEXT INTO TEXT BOX


End Sub

1条回答
干净又极端
2楼-- · 2019-05-13 13:28

Here is the solution:

Sub k()
    Dim Box As Shape
    Set Box = ActiveDocument.Shapes.AddTextbox( _
        Orientation:=msoTextOrientationHorizontal, _
        Left:=50, Top:=50, Width:=100, Height:=100)

        'The solution for you:
        Box.TextFrame.TextRange.Text = "My text comes this way"

End Sub
查看更多
登录 后发表回答