Determine if clipboard is empty

X

XP

Using Office 2003 and Windows XP;

Is it possible using VBA to determine if there are any contents in the
clipboard?

If so, could someone please post a generic example of how to do this?

Thanks much in advance.
 
I

ilia

For text data, try this:

Public Declare Function OpenClipboard Lib "user32" (ByVal hwnd As
Long) As Long
Public Declare Function CloseClipboard Lib "user32" () As Long
Public Declare Function GetClipboardData Lib "user32" (ByVal uFormat
As Long) As Long

Public Function isClipboardEmpty() As Boolean
OpenClipboard (0&)
isClipboardEmpty = (GetClipboardData(1) = 0)
CloseClipboard
End Function
 
D

Dana DeLouis

Just another option to test if the Clipboard is only holding an address
reference

Function LinkingModeQ() As Boolean
With Application
LinkingModeQ = .CutCopyMode = xlCopy Or .CutCopyMode = xlCut
End With
End Function

Sub Demo()
Range("A1").Copy
MsgBox LinkingModeQ

'// Windows: Linking mode compromised, therefore turned off
Application.CutCopyMode = False
MsgBox LinkingModeQ
End Sub
 

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

Top