Copy value of textbox to clipboard for use in another application

C

Connie

On a userform I have created, I would like to add a command button to copy the contents of a textbox on the form to the clipboard so that the user canpaste it to another application. I've searched the forum, but I don't seean easy way to do this. Does anyone know if it's possible? Thanks!
 
I

isabelle

hi Connie,

Dim MyData As DataObject
Set MyData = New DataObject
MyData.SetText TextBox1.Text
MyData.PutInClipboard

isabelle

Le 2013-10-05 23:22, Connie a écrit :
On a userform I have created, I would like to add a command button to copy the contents of a textbox on the form to the clipboard
so that the user can paste it to another application. I've searched the
forum, but I don't see an easy way to do this. Does anyone know if it's
possible? Thanks!
 
A

Auric__

Walter said:
In message <[email protected]> of Sun, 6
Oct 2013 05:57:57 in microsoft.public.excel.programming, Auric__


Why is the Windows API your personal preference?
At first sight, it seems much more complicated.
Does it offer advantages I can't see?

Largely because I do a lot of programming outside of Office, and in many
languages, there is no other way.

One place where I prefer a non-API method is "normal" VB (i.e. VB6), where
you simply do this:

Clipboard.SetText "text here"

But that doesn't work in VBA. Shrug.
 
I

isabelle

note:

to use the "DataObject" object, you must load the following library:
"Microsoft Forms 2.0 Object Library". this is the same library
when you insert a form (userform) in a projetVBA

isabelle

Le 2013-10-06 01:14, isabelle a écrit :
 

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