View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dan E[_2_] Dan E[_2_] is offline
external usenet poster
 
Posts: 102
Default UserForm TextBox to ActiveSheet TextBox over 256 characters

John,

The following worked for me. One thing to note is that, their would be less
of an issue if you used a textbox from the Control toolbox.

Private Sub CommandButton1_Click()
Set allText = UserForm1.TextBox1
Set txtBox2 = ActiveSheet.DrawingObjects(1)
For x = 1 To Len(allText) Step 250
theText = Mid(allText, x, 250)
txtBox2.Characters(Start:=x, Length:=250).Text = theText
Next
End Sub

You'll neet to change the numbers to suit your sheet and userform.

Dan E

"John Wilson" wrote in message
...
Repost.......

Hit a brick wall with this one and I'm sure it's possible (just not
for me at the moment).

Code is directly from the KB article for copying text between
textboxes using the character method. The problem is that my
"CopyFrom" textbox is on a UserForm and the "CopyTo" textbox
is on the Active sheet.

UserForm is named "Amendment"
The textbox on the UserForm is TextBox2
The TextBox on the Activesheet is TextBox22

What I'm trying to do is copy the text from the TextBox on the UserForm
to a TextBox on the Activesheet. A straight copy/paste works if the text

is under 256 characters but if it's over that, the TextBox on the Active
sheet
comes up blank.

Coding below:

Sub TextBox_To_TextBox()
Dim x As Integer
Dim txtBox1 As TextBox, txtBox2 As TextBox
Dim theText As String
Set txtBox1 = ActiveSheet.DrawingObjects(1)
' Above should reference UserForm "Amendment", "TextBox2"
Set txtBox2 = ActiveSheet.DrawingObjects(2)
' Above should reference Activesheet(Textbox22)
For x = 1 To txtBox1.Characters.Count Step 250
theText = txtBox1.Characters(start:=x, Length:=250).Text
txtBox2.Characters(start:=x, Length:=250).Text = theText
Next
End Sub

Any help with this would be certainly appreciated.

Thanks,
John