ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If clipboard is empty.. (https://www.excelbanter.com/excel-programming/450990-if-clipboard-empty.html)

Tonso

If clipboard is empty..
 
I have an XL 2013 workbook into which I paste data from an intranet webpage.
If a user forgets to copy the data before invoking the macro that pastes the data into the workbook and manipulates it, they get the Run-time error 1004.
When the user invokes the macro with the clipboard empty, I would like foe the macro to either end, or better yet, activate a message-box that tell the user what the problem is [empty clipboard], then exits the macro. How can I accomplish this?

Thanks,
Tonso

Claus Busch

If clipboard is empty..
 
Hi Tonso,

Am Mon, 20 Jul 2015 04:19:39 -0700 (PDT) schrieb Tonso:

I have an XL 2013 workbook into which I paste data from an intranet webpage.
If a user forgets to copy the data before invoking the macro that pastes the data into the workbook and manipulates it, they get the Run-time error 1004.
When the user invokes the macro with the clipboard empty, I would like foe the macro to either end, or better yet, activate a message-box that tell the user what the problem is [empty clipboard], then exits the macro. How can I accomplish this?


try:

If Application.ClipboardFormats(1) = -1 Then
MsgBox "Clipboard is empty"
Exit Sub
End If


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional

Tonso

If clipboard is empty..
 
On Monday, July 20, 2015 at 7:19:53 AM UTC-4, Tonso wrote:
I have an XL 2013 workbook into which I paste data from an intranet webpage.
If a user forgets to copy the data before invoking the macro that pastes the data into the workbook and manipulates it, they get the Run-time error 1004.
When the user invokes the macro with the clipboard empty, I would like foe the macro to either end, or better yet, activate a message-box that tell the user what the problem is [empty clipboard], then exits the macro. How can I accomplish this?

Thanks,
Tonso


Claus,
Thanks! Works perfect!
Tonso


All times are GMT +1. The time now is 07:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com