Check if clipboard is empty before .PasteSpecial xlPasteValues

S

Spaan

I use the sub auto_open() to prevent format to be copied in a copy paste.
With Application
.OnKey "^v", "ValueOnly"
End With

and then this function:
Function ValueOnly()
Selection.PasteSpecial xlPasteValues
End Function

However, the code failes when trying to paste when no cells are highlighted
(you know, after control-C for example). Probably the clipboad is empty which
causes the error. How do I check if the clipboard is empty so I can prevent
the error from happening? Or should I use On Error code to catch such an
event?

Furthermore, is there a way to capture the paste event when used through the
rightclick-menu, edit-menu and button?
(Excel97)
 
T

Tom Ogilvy

Function ValueOnly()
if Application.CutCopyMode = False then
msgbox "Nothing to paste"
else
Selection.PasteSpecial xlPasteValues
End if
End Function
 
T

Tom Ogilvy

in the workbook level selectionchange event, you can check

if application.CutcopyMode = xlCut then
application.cutcopymode = False
msgbox "there will be no cutting in this workbook"
end if
 
Top