如何在Word宏中的TextBox中插入文本

时间:2013-06-15 18:12:31

标签: vba textbox ms-word word-vba

我在Word中创建了一个文本框,我想在其中插入文本:

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 个答案:

答案 0 :(得分:3)

以下是解决方案:

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