Throw Exception if Clipboard is Empty

  • Thread starter Thread starter PumaMan
  • Start date Start date
P

PumaMan

I have a simple paste action in VBA:

Range("Q2").Select
ActiveSheet.Paste

I'd like to catch and throw an exception if the user's clipboard is empty.
Currently, the user gets the "End - Debug" general exception.

I appreciate any help!
 
Hi

You need to use the error handler:

On Error Resume Next
Range("Q2").Select
ActiveSheet.Paste
If Err.Number = 1004 Then
msg = MsgBox(Err.Description)
End If
Err.Clear


Regards,
Per
 
Range("Q2").Select
Selection.PasteSpecial xlPasteValues

or

Range("q2").PasteSpecial xlPasteAll
 
I have a simple paste action in VBA:

    Range("Q2").Select
    ActiveSheet.Paste

I'd like to catch and throw an exception if the user's clipboard is empty..  
Currently, the user gets the "End - Debug" general exception.

I appreciate any help!

How about something like...

If Application.ClipboardFormats(1) = -1 Then
MsgBox "Clipboard Empty!"
End If

....Ron
 
Back
Top