Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default Copy variable to clipboard

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Copy variable to clipboard

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" wrote in message
...
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Copy variable to clipboard

On Jan 7, 4:33 pm, Greg Glynn 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
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Copy variable to clipboard

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Putting a variable value into the Clipboard Greg de Bruin Excel Programming 2 December 5th 07 01:13 PM
Transfer clipboard from Task pane clipboard(office?) content to Excel (windows?) clipboard? tskogstrom Excel Programming 2 March 6th 07 12:50 PM
Copy from clipboard? G Lam[_2_] Excel Programming 1 November 24th 04 09:05 AM
Set variable to clipboard contents? Fred Smith Excel Programming 2 September 5th 04 08:23 PM


All times are GMT +1. The time now is 01:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"