JeffT
02-16-2011, 03:44 PM
Hi
I wonder if there is anyway to check if the clipboard contains data before attempting to Paste.
The data will be copied from a .txt file then pasted into Excel to do a lot of modifications. I'm using a manual copy from the text file then using code to paste so I can carry out some modifications before the data is seen. If the Clipboard contains data then all works OK, if not I get an error "Paste method of worksheet class failed".
I could use an On Error statement to catch the error but by then I've created a new sheet and would have to delete it again. All is possible but I'd rather know if there is nothing to paste before the Sub gets too far.
Also is it possible to determine how many lines of text there are in the clipboard data as in some instances it may be that there will be more than 65536 so the spreadsheet would run out of room (xl2003) when the data is pasted. I was going to try it out to see if an error came up or if the paste was truncated then decide how to solve it, but it'd be good if I could use the same check to do both.
Hope you can help
Regards
Jeff T
I wonder if there is anyway to check if the clipboard contains data before attempting to Paste.
The data will be copied from a .txt file then pasted into Excel to do a lot of modifications. I'm using a manual copy from the text file then using code to paste so I can carry out some modifications before the data is seen. If the Clipboard contains data then all works OK, if not I get an error "Paste method of worksheet class failed".
I could use an On Error statement to catch the error but by then I've created a new sheet and would have to delete it again. All is possible but I'd rather know if there is nothing to paste before the Sub gets too far.
Also is it possible to determine how many lines of text there are in the clipboard data as in some instances it may be that there will be more than 65536 so the spreadsheet would run out of room (xl2003) when the data is pasted. I was going to try it out to see if an error came up or if the paste was truncated then decide how to solve it, but it'd be good if I could use the same check to do both.
Hope you can help
Regards
Jeff T