Forum Discussion

a_bonsey's avatar
a_bonsey
Brass Contributor
May 18, 2022

text and variables wrapping when placed in new text box

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")

 

 

 

  • 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.
    • a_bonsey's avatar
      a_bonsey
      Brass Contributor
      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?

Resources