Copying text from text box

D

Daniel Bonallack

Is there any way to copy out the text from a text box to a cell, even when
the text length is greater than 255 characters?

Currently, my copy is getting truncated to the first 255 characters.

thanks in advance
Daniel
 
C

Charlie

It's working ok for me:

TextBox1.Value = Space(20000)
Cells(1, 1).Value = TextBox1.Value
Debug.Print Len(Cells(1, 1))

check the MaxLength property of your textbox. Set it to zero.
 
D

Daniel Bonallack

Hi Charlie,

Thanks for the solution, but I think I didn't post very clearly. I'm
talking about an actual drawing object textbox, rather than a textbox in a
form. Any thoughts on that?

Daniel
 
B

Bob Phillips

Hi Daniel,

Long time no hear.

Try this


Sub LoadCellFromTextbox()
Dim tbox As Shape
Dim tmp As String
Dim tbLen As Long
Dim i As Long

Set tbox = ActiveSheet.Shapes("Text Box 1")
tbLen = tbox.TextFrame.Characters.Count
For i = 1 To tbLen Step 255

tmp = tmp & tbox.TextFrame.Characters(i, 255).Text
Next i
ActiveCell.Value = tmp
End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

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

Top