View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Check if clipboard is empty before .PasteSpecial xlPasteValues

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

--
Regards,
Tom Ogilvy

"Spaan" wrote in message
...
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)