VB and VBA Users Source Code: Copying data to and from Excel to the clipboard using the data object
[
Home
|
Contents
|
Search
|
Reply
| Previous |
Next
]
VB/VBA Source Code
Copying data to and from Excel to the clipboard using the data object
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Tuesday, November 13, 2001
Hits:
1763
Category:
Unspecified
Article:
The following routines can be used to copy data to and from the clipboard in Excel. Option Explicit 'Purpose : Copys text from Excel to the Clipboard. 'Inputs : sText The text to send to the clipboard. 'Output : N/A 'Author : Andrew Baker (copyright www.vbusers.com) 'Date : 03/05/2001 13:50 'Notes : IMPORTANT NOTE: You will need to reference "Microsoft Forms X.X" (FM20.DLL) where ' X.X is greater than or equal to 2. If you add a userform to your workbook ' Excel will automatically add this reference for you. 'Revisions : Function ClipboardSetText(sText As String) As Boolean Dim oDataObject As DataObject On Error Resume Next Set oDataObject = New DataObject oDataObject.SetText sText, 1 oDataObject.PutInClipboard Set oDataObject = Nothing On Error GoTo 0 End Function 'Purpose : Gets text from the Clipboard to Excel. 'Inputs : N/A 'Output : The text on the clipboard 'Author : Andrew Baker (copyright www.vbusers.com) 'Date : 03/05/2001 13:50 'Notes : You will need to reference "Microsoft Forms X.X" (FM20.DLL) where ' X.X is greater than or equal to 2. If you add a userform to your workbook ' Excel will automatically add this reference for you. 'Revisions : Function ClipboardGetText() As String Dim oDataObject As DataObject On Error Resume Next Set oDataObject = New DataObject oDataObject.GetFromClipboard ClipboardGetText = oDataObject.GetText(1) Set oDataObject = Nothing On Error GoTo 0 End Function
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder