![]() To illistrate this and check to see how your clipboard content is stored, view it from Excel as shown below. It won't necessarily be text then, but this resolves the error for pasting an Excel Range. You can handle this by not specifying a format and a default format will be used. It also throws this error if the clipboard data cannot be converted to text (like a picture). PasteSpecial method of Worksheet class failed So it doesn't throw error if the office clipboard is empty, in fact, it throws an error for the opposite condition where an excel range is copied if it's being forced to use Text as its format. Range.PasteSpecial works off of the Office clipboard, while Workbook.PasteSpecial works off of the system or Windows clipboard. ![]() For instance, Application.CutCopyMode only controls the office clipboard. Turns out, there is an office clipboard and a Windows clipboard. PasteSpecial method of Range class failedįor Range.PasteSpecial under the following conditions: If that's accurate, I suspect that the Worksheet method calls the range method at some point. I find it odd that the error you're getting says that a range method failed if you're calling the worksheet method. Regarding the method, the Worksheet.PasteSpecial method is entirely different from the Range.PasteSpecial. ![]() However, your problem might be that you're getting data incompatable with a text format as discussed below. I think your use of ActiveSheet.PasteSpecial is probably fine, based on the testing you've done and this MSDN Documentation. MsgBox "Paste failed because of operation timeout", vbCritical Loop Until (Err.Number = 0 Or TimeoutCounter > TimeoutLimit ) On Error Resume NextĪctiveSheet.PasteSpecial Format:="Text", Link:=False, DisplayAsIcon:=False The code below will solve this issue while maintaining a responsive UI and reasonable timeout and notification. The OP diagnosed the problem as being a concurrency issue where the clipboard was not copied to in time for the paste operation. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |