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

标签 vba textbox ms-word

我在 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

最佳答案

解决方法如下:

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

关于vba - 如何在Word宏中的TextBox中插入文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17126517/

相关文章:

c# - 文本框验证 - C#

c# - Windows 窗体中用于实时搜索的文本框

vba - 在 MSWord 表的第一列中创建书签

excel - 将 Word 文档中的数据提取到 Excel 电子表格

vba - If-then/为单元格引用中定义的日期范围选择案例

excel - 如何循环遍历范围并将值分配给参数

vb.net - 从 DataGridView 选定单元格获取文本

c# - 在云环境中使用 C# 将 Word (DOCX) 文件转换为 PDF

excel - 不同长度的多维数组中的 Ubound?

excel - VBA - 检查字符串中是否存在 "Comma"