I need to clear clipboard from Excel 2003 SP1 VBA. I found couple codes that should do it, but none of them work for me.
This code returns an error message "User-defined type not defined":
Public Sub ClearClipboard()
Dim MyDataObj As New DataObject
MyDataObj.SetText ""
MyDataObj.PutInClipboard
End Sub
This code does not error, but it does not do anything either:
Declare Function CloseClipboard Lib "user32" () As Long
Declare Function EmptyClipboard Lib "user32" () As Long
Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Sub ClearAllClipboard()
OpenClipboard 0&
EmptyClipboard
CloseClipboard
End Sub
What am I doing wrong? Thank you for your help.
This code returns an error message "User-defined type not defined":
Public Sub ClearClipboard()
Dim MyDataObj As New DataObject
MyDataObj.SetText ""
MyDataObj.PutInClipboard
End Sub
This code does not error, but it does not do anything either:
Declare Function CloseClipboard Lib "user32" () As Long
Declare Function EmptyClipboard Lib "user32" () As Long
Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Sub ClearAllClipboard()
OpenClipboard 0&
EmptyClipboard
CloseClipboard
End Sub
What am I doing wrong? Thank you for your help.