Throw Exception if Clipboard is Empty

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!
 
P

Per Jessen

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
 
M

muddan madhu

Range("Q2").Select
Selection.PasteSpecial xlPasteValues

or

Range("q2").PasteSpecial xlPasteAll
 
R

ron

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
 

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