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) |
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) |
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) |
All times are GMT +1. The time now is 03:40 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com