ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Warn if no text in clipboard contents (https://www.excelbanter.com/excel-programming/424529-warn-if-no-text-clipboard-contents.html)

John[_140_]

Warn if no text in clipboard contents
 
I have the following sub (Excel 2007):
ActiveSheet.PasteSpecial Format:="Text"

It fails if there is no text to paste. I'd like a MsgBox to prompt the user
if there is no text. How do I do this?

Also, is there some way I can warn if the text will paste to more than one
cell?

Thanks



Gary''s Student

Warn if no text in clipboard contents
 
Function ValueOnly()
if Application.CutCopyMode = False then
msgbox "Nothing to paste"
else
ActiveSheet.PasteSpecial Format:="Text"
End if
End Function

--
Gary''s Student - gsnu2007L


"John" wrote:

I have the following sub (Excel 2007):
ActiveSheet.PasteSpecial Format:="Text"

It fails if there is no text to paste. I'd like a MsgBox to prompt the user
if there is no text. How do I do this?

Also, is there some way I can warn if the text will paste to more than one
cell?

Thanks




Alan Moseley

Warn if no text in clipboard contents
 
I can help with your first question:-

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

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"John" wrote:

I have the following sub (Excel 2007):
ActiveSheet.PasteSpecial Format:="Text"

It fails if there is no text to paste. I'd like a MsgBox to prompt the user
if there is no text. How do I do this?

Also, is there some way I can warn if the text will paste to more than one
cell?

Thanks





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

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