0

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.

2 Answers 2

1

Impossible to say w/o a 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
Sign up to request clarification or add additional context in comments.

Comments

0

Its because its a shape. Get the shapes collection and locate the label then access the TextFrame2.TextRange.text

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.