Check for blank clipboard

  • Thread starter Thread starter Mr. Clean
  • Start date Start date
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top