Text and TextBox problem

  • Thread starter Thread starter Stuart
  • Start date Start date
S

Stuart

With a textbox from the Drawing toolbar, how do I
programmatically load the textbox with loads of text?

ActiveSheet.Shapes("Text Box 10").Visible = True
ActiveSheet.Shapes("Text Box 10").Select
' Selection.Text = "ABC" 'this works
'the following does not work
Selection.Text = _
"Use this Fax template to create the first Fax for a new" & _
vbNewLine & "Contract." & vbNewLine & vbNewLine _
& "Enter all those items that will be 'standard' for every Fax."

Regards.
 
Stuart,

Try something like the following:

Dim SH As Shape
Set SH = ActiveSheet.Shapes("Text Box 1")
SH.TextFrame.Characters.Text = "this is some text" & vbLf & _
"this is some more text"



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Suggested is that you use vbLf instead of vbNewLine and
otherwise let the textbox automatically wrap the text.
Note that you don't need to select the textbox.

Sub LoadText()
Dim Msg As String
Msg = "INSTRCTIONS:" & vbLf & "Use this Fax template " & _
"to create the first Fax for a new Contract. Enter " & _
"those items that will be 'standard' for every Fax."
With ActiveSheet.Shapes("Text Box 10")
.Visible = True
.TextFrame.Characters.Text = Msg
End With
End Sub

Regards,
Greg
 
Many thanks to you both.

Regards.

Chip Pearson said:
Stuart,

Try something like the following:

Dim SH As Shape
Set SH = ActiveSheet.Shapes("Text Box 1")
SH.TextFrame.Characters.Text = "this is some text" & vbLf & _
"this is some more text"



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top