Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Check if clipboard is empty before .PasteSpecial xlPasteValues

I use the sub auto_open() to prevent format to be copied in a copy paste.
With Application
.OnKey "^v", "ValueOnly"
End With

and then this function:
Function ValueOnly()
Selection.PasteSpecial xlPasteValues
End Function

However, the code failes when trying to paste when no cells are highlighted
(you know, after control-C for example). Probably the clipboad is empty which
causes the error. How do I check if the clipboard is empty so I can prevent
the error from happening? Or should I use On Error code to catch such an
event?

Furthermore, is there a way to capture the paste event when used through the
rightclick-menu, edit-menu and button?
(Excel97)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Check if clipboard is empty before .PasteSpecial xlPasteValues

Function ValueOnly()
if Application.CutCopyMode = False then
msgbox "Nothing to paste"
else
Selection.PasteSpecial xlPasteValues
End if
End Function

--
Regards,
Tom Ogilvy

"Spaan" wrote in message
...
I use the sub auto_open() to prevent format to be copied in a copy paste.
With Application
.OnKey "^v", "ValueOnly"
End With

and then this function:
Function ValueOnly()
Selection.PasteSpecial xlPasteValues
End Function

However, the code failes when trying to paste when no cells are

highlighted
(you know, after control-C for example). Probably the clipboad is empty

which
causes the error. How do I check if the clipboard is empty so I can

prevent
the error from happening? Or should I use On Error code to catch such an
event?

Furthermore, is there a way to capture the paste event when used through

the
rightclick-menu, edit-menu and button?
(Excel97)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Check if clipboard is empty before .PasteSpecial xlPasteValues

in the workbook level selectionchange event, you can check

if application.CutcopyMode = xlCut then
application.cutcopymode = False
msgbox "there will be no cutting in this workbook"
end if

--
Regards,
Tom Ogilvy

"Spaan" wrote in message
...
Thx a bunch. Work perfect for teh issue I discribed. However, I've just
discoverd that when doing a cut paste (instead of a copy paste), the error
also occurs. Also with the code you provided.
I've looked bit further into the CutCopyPaste property and I can catch

the
event of a cut and paste (Application.CutCopyMode = xlCut). But apparently
the Selection.PasteSpecial doesn't work for cut and paste. This is

confirmed
by the fact that Paste Special option is also not available in the menus

when
doing a cut.

So am I right to assume that preventing the format to be copied along with
the data in case of a Cut 'n' Paste is simply not possible?

"Tom Ogilvy" wrote:

Function ValueOnly()
if Application.CutCopyMode = False then
msgbox "Nothing to paste"
else
Selection.PasteSpecial xlPasteValues
End if
End Function

--
Regards,
Tom Ogilvy

"Spaan" wrote in message
...
I use the sub auto_open() to prevent format to be copied in a copy

paste.
With Application
.OnKey "^v", "ValueOnly"
End With

and then this function:
Function ValueOnly()
Selection.PasteSpecial xlPasteValues
End Function

However, the code failes when trying to paste when no cells are

highlighted
(you know, after control-C for example). Probably the clipboad is

empty
which
causes the error. How do I check if the clipboard is empty so I can

prevent
the error from happening? Or should I use On Error code to catch such

an
event?

Furthermore, is there a way to capture the paste event when used

through
the
rightclick-menu, edit-menu and button?
(Excel97)






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 tomcat3 Excel Discussion (Misc queries) 13 July 7th 06 09:11 PM
ActiveCell.PasteSpecial (xlPasteValues) hangs program hals_left Excel Programming 3 June 9th 04 11:18 AM
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 06:48 AM.

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"