PC Review


Reply
Thread Tools Rate Thread

Copy variable to clipboard

 
 
Greg Glynn
Guest
Posts: n/a
 
      8th Jan 2008
Is there a better way to copy the contents of a variable into the
clipboard (other than, as below, copy it to a temporary cell)

MyString = "Put this in to the clipboard"
Range("A100") = MyString
Range("A100").Copy
Range("A100").ClearContents

Regards


Greg
 
Reply With Quote
 
 
 
 
Chip Pearson
Guest
Posts: n/a
 
      8th Jan 2008
The following code will put the text of the active cell into the clipboard.
You'll need a reference to the Forms type library. In VBA, go to the Tools
menu, choose References, and check "Microsoft Forms 2.0 Object Library" (or,
just add a UserForm -- the reference will be automatically added).

Sub CopyToClipboard()
Dim DataObj As New MSForms.DataObject
DataObj.SetText ActiveCell.Text
DataObj.PutInClipboard
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"Greg Glynn" <(E-Mail Removed)> wrote in message
news:3a7f36da-9b42-4c48-88e9-(E-Mail Removed)...
> Is there a better way to copy the contents of a variable into the
> clipboard (other than, as below, copy it to a temporary cell)
>
> MyString = "Put this in to the clipboard"
> Range("A100") = MyString
> Range("A100").Copy
> Range("A100").ClearContents
>
> Regards
>
>
> Greg


 
Reply With Quote
 
itsthedude@gmail.com
Guest
Posts: n/a
 
      8th Jan 2008
On Jan 7, 4:33 pm, Greg Glynn <GregoryGl...@gmail.com> wrote:
> Is there a better way to copy the contents of a variable into the
> clipboard (other than, as below, copy it to a temporary cell)
>
> MyString = "Put this in to the clipboard"
> Range("A100") = MyString
> Range("A100").Copy
> Range("A100").ClearContents
>
> Regards
>
> Greg


Dim mystring As New DataObject


If usf_Convert.tbo_Number_is <> "" Then

number_is.SetText usf_Convert.tbo_Number_is
number_is.PutInClipboard
End If
 
Reply With Quote
 
itsthedude@gmail.com
Guest
Posts: n/a
 
      8th Jan 2008
hit enter by accident while editing some code i had already... anyway

Dim mystring As New DataObject
mystring.SetText "Put In Clipboard"
mystring.PutInClipboard
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy contents of variable into clipboard Simka Microsoft Excel Programming 6 29th Oct 2008 04:35 PM
Copy a Variable to the Clipboard =?Utf-8?B?TGFtYXI=?= Microsoft Access Form Coding 1 23rd Mar 2007 07:11 PM
Clipboard gets empty by itself, cleared clipboard, copy paste doesn't work, outlook clears clipboard, problems with clipboard - possible solution Jens Hoerburger Microsoft Outlook 0 24th Aug 2006 02:44 PM
copy variable to clipboard Terry Holland Microsoft Access Form Coding 2 2nd Aug 2005 12:18 PM
How to copy string variable to clipboard Douglas J. Steele Microsoft Access 2 21st Aug 2004 08:57 PM


Features
 

Advertising
 

Newsgroups
 


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