Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I send a variable to the clipboard ?

VBA How To

How can I send a variable to the clipboard ?

by  Chance1234  Posted    (Edited  )
Firstly you will need to set a reference to the Microsoft forms 2.0 collection.

Insert a new module and copy / paste the following

Code:
Sub subCopyPasteVariableToClipboard()
Dim do_Mydata As DataObject 'set reference to the data object ,part of microsoft forms 2.0
Dim str_test As String ' string for testing

Set do_Mydata = New DataObject

str_test = "This should be sent to the clipboard"

    With do_Mydata
        .SetText str_test
        .PutInClipboard
    End With

End Sub

Run the code, open up notepad and press CTRL + V

"This should be sent to the clipboard" should appear.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top