ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy value of textbox to clipboard for use in another application (https://www.excelbanter.com/excel-programming/449338-copy-value-textbox-clipboard-use-another-application.html)

Connie

Copy value of textbox to clipboard for use in another application
 
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!

isabelle

Copy value of textbox to clipboard for use in another application
 
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!


Auric__

Copy value of textbox to clipboard for use in another application
 
isabelle wrote:

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!


hi Connie,

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


For other options (including the Windows API, my personal preference) see
"How to: Send Information to the Clipboard" at MSDN:

http://msdn.microsoft.com/en-us/libr.../ff192913.aspx

--
Ooh, it pulses. With... what kind of magic? Fate?

Walter Briscoe

Copy value of textbox to clipboard for use in another application
 
In message of Sun, 6
Oct 2013 05:57:57 in microsoft.public.excel.programming, Auric__
writes
isabelle wrote:

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!


hi Connie,

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


For other options (including the Windows API, my personal preference) see
"How to: Send Information to the Clipboard" at MSDN:

http://msdn.microsoft.com/en-us/libr.../ff192913.aspx


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

Auric__

Copy value of textbox to clipboard for use in another application
 
Walter Briscoe wrote:

In message of Sun, 6
Oct 2013 05:57:57 in microsoft.public.excel.programming, Auric__
writes

For other options (including the Windows API, my personal preference) see
"How to: Send Information to the Clipboard" at MSDN:

http://msdn.microsoft.com/en-us/libr.../ff192913.aspx


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.

--
Anybody who thinks a little 9,000-line program that's distributed
free and can be cloned by anyone is going to affect anything we do
at Microsoft has his head screwed on wrong.
-- Bill Gates

isabelle

Copy value of textbox to clipboard for use in another application
 
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 :
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!



All times are GMT +1. The time now is 02:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com