Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 将文本添加到文本框宏_Vba_Powerpoint - Fatal编程技术网

Vba 将文本添加到文本框宏

Vba 将文本添加到文本框宏,vba,powerpoint,Vba,Powerpoint,为什么这段代码不能将文本添加到文本框中?我肯定语法有问题,但不确定在哪里 Label5.Text = "Add Text" 谢谢。这是因为它是一个形状。获取shapes集合并找到标签,然后访问TextFrame2.TextRange.text不可能说没有更广泛的代码位 如果文本框实际上是ActiveX标签(如其名称所示),则如下所示: Sub thing() Dim oSh As Shape Set oSh = ActiveWindow.Selection.ShapeR

为什么这段代码不能将文本添加到文本框中?我肯定语法有问题,但不确定在哪里

    Label5.Text = "Add Text"

谢谢。

这是因为它是一个形状。获取shapes集合并找到标签,然后访问
TextFrame2.TextRange.text

不可能说没有更广泛的代码位

如果文本框实际上是ActiveX标签(如其名称所示),则如下所示:

Sub thing()
    Dim oSh As Shape
    Set oSh = ActiveWindow.Selection.ShapeRange(1)

    oSh.OLEFormat.Object.Caption = "Some text"

End Sub
如果是普通文本框或其他可包含文本的形状:

Sub thing()
    Dim oSh As Shape
    Set oSh = ActiveWindow.Selection.ShapeRange(1)

    oSh.TextFrame.TextRange.Text = "Some text"

End Sub