TextBox1.Copy will copy the whole actual Control Object not its Text .
one way is to use the DataObject Class which requires a reference to the MsForms library before it can be used.
here is function that will do the job :
Function CopyTextBox_Text(oTextBox As MSForms.TextBox) As Boolean
Dim oData As DataObject
Set oData = New DataObject
If Len(oTextBox.Text) <> 0 Then
CopyTextBox_Text = True
and here is test routine that pastes the contents of TextBox1 onto Cell A1 :
If CopyTextBox_Text(Me.TextBox1) Then
MsgBox "No text to paste !", vbExclamation
Well... what should i say... i am more confused then i was before... cuz neither of codes worked for me... I am still scratching my head and seeking the info thru Google... I have to say that i really didn't thought that copying the text to windows clipboard will be such a difficult task... anyways Pals keep me posted if you come to know anything
This topic is getting more interesting then i ever thought about it....
I simply shortened your code as per my requirement:
Private Sub CommandButton1_Click()
TextBox1.SelStart = 0
TextBox1.SelLength = Len(TextBox1.Text)
It worked fine when i placed the Text Box and command Button on a User Form, But to my Surprise, when i kicked in the same controls on Excel sheet (instead of Form) and pasted the same code... it actually copied the control itself....