Why doesn't this code work to add text to textbox? I am sure the syntax is off somewhere, but not sure where.
Label5.Text = "Add Text"
Thanks.
Impossible to say w/oa more extensive bit of code.
If the text box is actually an ActiveX Label (as suggested by its name), then like so:
Sub thing()
Dim oSh As Shape
Set oSh = ActiveWindow.Selection.ShapeRange(1)
oSh.OLEFormat.Object.Caption = "Some text"
End Sub
If it's a normal text box or other shape that can contain text:
Sub thing()
Dim oSh As Shape
Set oSh = ActiveWindow.Selection.ShapeRange(1)
oSh.TextFrame.TextRange.Text = "Some text"
End Sub
Its because its a shape. Get the shapes collection and locate the label then access the TextFrame2.TextRange.text
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.