View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
ron ron is offline
external usenet poster
 
Posts: 118
Default Copy the contents of variable into clipboard

On Oct 29, 8:40*am, Simka wrote:
Hi ron,

I'm not sure how to understand what you have written below, but I think you
are on the right lines and understanding what I am trying to achieve.

I'm not too familiar with Class Modules, I find them a little confusing. Can
you write the code in full so that I can copy it to modules/class modules and
then I can follow what you are thinking?

Cheers,

Simka.



"ron" wrote:
On Oct 28, 10:59 am, Simka wrote:
Hi everyone,


My head has gone blank. I am trying to copy the contents of a variable into
the clipboard.


ie:
value in clipboard = MyVariable


Can someone please remind me?


Try the following...ron


* * Dim mystring As New DataObject


* * my_var= "assign something to the variable"


* * mystring.SetText my_var
* * mystring.PutInClipboard
* * ActiveSheet.PasteSpecial Format:="Text"- Hide quoted text -


- Show quoted text -


Hi Simka...Just copy and paste the following code into a module.
Assign whatever it is that you want to move to the clipboard to
"my_var". The ActiveSheet.Paste line simply demonstrates that you
have copied the information to the clipboard. Change or delete this
line depending on what you want to do with the information once it is
in the clipboard...ron

Sub CopyToClipboard()

Dim mystring As New DataObject

my_var = "assign something to the variable"

mystring.SetText my_var
mystring.PutInClipboard

ActiveSheet.PasteSpecial Format:="Text"

End Sub