• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Problem with Copy and Paste from excel

I am having some issues when copying and then pasting from excel. I have set some codes to copy from Textbox or Combobox. When I execute the code, it copies on the clipboard what I need, but when I paste it, it doesn´t work. It only pastes a couple of small squares " □ □ ". What should I do to fix this?

This is the code that I am using to copy to the clipboard.

>>> use code - tags <<<
Code:
Private Sub CommandButton2_Click()
With New MSForms.DataObject
    .SetText TextBox1.Text
    .PutInClipboard
    End With
    Unload Me

End Sub
I would appreciate it if you can help me to explain to me how to fix this issue. P.S: I am using Windows 10 and Office 2013
 
Last edited by a moderator:

Belleke

Well-Known Member
Maybe?
Code:
Private Sub CommandButton1_Click()
 With TextBox1
      .SelStart = 0
      .SelLength = Len(.Text)
      .Copy
   End With
Unload Me
End Sub
 
Code:
Private Sub CommandButton11_Click()
    With Label10
      .SelStart = 0
      .SelLength = Len(.Caption)
      .Copy
   End With
Unload Me
End Sub
It gives me an error message "Method or data member not found"
 

Attachments

Top