SOLVED

text and variables wrapping when placed in new text box

Occasional Contributor

In the snippet of code below the text box that's created wraps to the next line (see image).
The 'item' variable is then followed by the 'perBox' variable and the static text 'in 'Full Boxes' but there is a line break after the 'item' variable.

What causes this and how can I stop it?

 

TIA

 

Set TextBox = ActiveDocument.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, Left:=250, Top:=150, Width:=300, Height:=60)
With TextBox
With .TextFrame.TextRange
.Text = strTextBox
.Font.Name = "Arial"
.Font.Size = 10
End With
.Line.Visible = msoFalse
End With

TextBox.TextFrame.TextRange.Text = (item & ": x" & perBox & " in Full Boxes")

 

 

a_bonsey_0-1652886065843.png

 

3 Replies
Why are you using TextBoxes?
The only reason that I would be using TextBoxes would be if I needed to have one linked to another so that text would flow from one to another over some other object.
I was using a text box to position new text at a given position on the page and apply styling to it.
What would you receommend that works instead and makes the new text appear correctly?
best response confirmed by a_bonsey (Occasional Contributor)
Solution

@a_bonsey I would use a Table.