If you want to test whether the user is in the process of a copy or
cut operation within Excel, you can use
Select Case Application.CutCopyMode
Case xlCopy
Debug.Print "Copy in progress"
Case xlCut
Debug.Print "Cut in progress"
Case Else
Debug.Print "No copy/cut in progress"
End Select
This returns that status of Excel's clipboard, returning true if there
is a copy or cut pending (the range has the marching ants border). You
can cancel the copy/cut mode with
Application.CutCopyMode = False
If you really need to see if *anything* (including non-Excel related
stuff) is in the clipboard, use
Public Declare Function CountClipboardFormats Lib "user32" () As Long
Sub AAA()
Dim N As Long
N = CountClipboardFormats()
If N = 0 Then
Debug.Print "nothing on clipboard"
Else
Debug.Print "something on clipboard"
End If
End Sub
If you want to totally clear the clipboard, use
Public Declare Function OpenClipboard Lib "user32" (ByVal hwnd As
Long) As Long
Public Declare Function CloseClipboard Lib "user32" () As Long
Public Declare Function EmptyClipboard Lib "user32" () As Long
Sub ClearClipboard()
OpenClipboard 0&
EmptyClipboard
CloseClipboard
End Sub
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)