Send to and retrieve from Windows Clipboard
2009-05-05 VBA programming 0 637
The procedures below can be used to send text and numbers to the Windows Clipboard They all require a reference to the Microsoft Forms 2.x Object Library.
Sub SendToClipboard(varItem As Variant)
' sends varItem to the Windows Clipboard as text
Dim objDO As DataObject
Set objDO = New DataObject
With objDO
.SetText varItem
.PutInClipboard
End With
Set objDO = Nothing
End Sub
Function GetFromClipboard() As Variant
' returns the current content from the Windows Clipboard
Dim objDO As DataObject
Set objDO = New DataObject
With objDO
.GetFromClipboard
GetFromClipboard = .GetText
End With
Set objDO = Nothing
End Function
Sub ClearClipboardContent()
' clears the Windows Clipboard content
SendToClipboard vbNullString
End Sub