Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
tod tod is offline
external usenet poster
 
Posts: 114
Default Test if Clipboard is empty

Here is my newbie question o' the day.

Is there a way I can test if something has been copied to
the clipboard?

Extra super monster bonus question:

Is there a way to also test if the data that has been
copied to the clipboard is cell values (vs an object or
some non-excel data)?

tod
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Test if Clipboard is empty

Tod,

You can use the CutCopyMode property to determine whether Excel
is in Copy mode (CutCopyMode = 1 = xlCopy), Cut mode (CutCopyMode
= 2 = xlCut) or neither (CutCopyMode = 0)

When you copy data to the clipboard in Excel, a few dozen data
formats are place in the clipboard. To determine whether an Excel
data type (e.g., BIFF8) is in the clipboard, you need to
enumerate all the data formats on the clipboard, testing each
one. For example,


Public Declare Function EnumClipboardFormats Lib "user32" _
(ByVal wFormat As Long) As Long
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
Public Declare Function GetClipboardFormatName Lib "user32" _
Alias "GetClipboardFormatNameA" _
(ByVal wFormat As Long, ByVal lpString As String, _
ByVal nMaxCount As Long) As Long

Public Declare Function CountClipboardFormats Lib "user32" () As
Long
Public Declare Function IsClipboardFormatAvailable Lib "user32" _
(ByVal wFormat As Long) As Long
Public Declare Function GetClipboardData Lib "user32" _
Alias "GetClipboardDataA" (ByVal wFormat As Long) As Long

Const cBIFF8Format = 49755


Sub AAA()

Dim R As Long
Dim S As String
Dim O As Object

Selection.Copy
OpenClipboard 0
Do
R = EnumClipboardFormats(R)
S = String(255, 0)
GetClipboardFormatName R, S, Len(S)
Debug.Print R, S
Loop Until R = 0
Debug.Print "Format Count:", CountClipboardFormats
Debug.Print "Excel Data Available:",
IsClipboardFormatAvailable(cBIFF8Format)

CloseClipboard

End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Tod" wrote in message
...
Here is my newbie question o' the day.

Is there a way I can test if something has been copied to
the clipboard?

Extra super monster bonus question:

Is there a way to also test if the data that has been
copied to the clipboard is cell values (vs an object or
some non-excel data)?

tod



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot empty the clipboard Jaleel Excel Discussion (Misc queries) 1 November 22nd 09 08:57 PM
Clipboard empty but still get waring that clipboard is full Steve Excel Discussion (Misc queries) 0 June 17th 08 09:05 PM
Clipboard empty but get cannot empty CB when trying to copy Peter @ ServiceMaster Excel Worksheet Functions 0 February 22nd 07 03:58 PM
Cannot empty the clipboard cjones Excel Discussion (Misc queries) 0 August 9th 06 11:10 PM
cannot empty the clipboard tomcat3 Excel Discussion (Misc queries) 13 July 7th 06 09:11 PM


All times are GMT +1. The time now is 07:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"