Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Throw Exception if Clipboard is Empty

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!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Throw Exception if Clipboard is Empty

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

"PumaMan" skrev i meddelelsen
...
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!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default Throw Exception if Clipboard is Empty

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

or

Range("q2").PasteSpecial xlPasteAll


On Oct 19, 6:46*pm, PumaMan wrote:
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!


  #4   Report Post  
Posted to microsoft.public.excel.programming
ron ron is offline
external usenet poster
 
Posts: 118
Default Throw Exception if Clipboard is Empty

On Oct 19, 7:46*am, PumaMan wrote:
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
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
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 OhWellJon Excel Discussion (Misc queries) 0 September 19th 06 07:19 PM
Cannot empty the clipboard cjones Excel Discussion (Misc queries) 0 August 9th 06 11:10 PM
Why is my clipboard empty? Ed[_9_] Excel Programming 3 November 6th 03 11:08 PM


All times are GMT +1. The time now is 04:42 PM.

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"