Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
"PasteSpecial method of Range class failed" when range Number of Rows 2000
I am having a problem with the Range.PasteSpecial Method, in C#..
Below is my code... Basically, I am trying to copy the format from the ENTIRE first row, and paste it to the other rows in teh document... this code WORKS FINE when the paste-to range is only like 200 lines, or less... When the PasteTo range is like 5000,10000 (keep in mind the copied range is still just one measly row, so the clipboard shouldn't be getting over flowed), etc. this is where I received the following error " Excel.ApplicationClass ex = new Microsoft.Office.Interop.Excel.ApplicationClass(); (ex as Excel.Application).Visible = true; Excel.Workbook wb = (ex as Excel.Application).Workbooks.Open( _excelPath,missing,missing,missing, missing,missing,missing,missing,missing,missing,mi ssing, missing,missing,missing,missing); wb.Activate(); Console.WriteLine("done with excel lo"); Excel.Worksheet ws = wb.ActiveSheet as Excel.Worksheet; Excel.Range r = ws.get_Range("A14", "U14"); r = r.EntireRow; ex.CutCopyMode = Excel.XlCutCopyMode.xlCopy; r.Copy(missing); Excel.Range r2 = ws.get_Range("A15", "U5000"); //WHEN you put in U1000/U2000, it takes a long time, but it still works..... ex.ScreenUpdating = false; try { r2.PasteSpecial(Microsoft.Office.Interop.Excel.XlP asteType.xlPasteFormats, Microsoft.Office.Interop.Excel.XlPasteSpecialOpera tion.xlPasteSpecialOperationNone, missing, missing); } catch (Exception ex1) { Console.Error.WriteLine(ex1.Message); } |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
"Select method of Range class failed" Error | Excel Discussion (Misc queries) | |||
Run-time error "1004" Select method of range class failed | Excel Discussion (Misc queries) | |||
VBA error 1004 "Select method of Range class failed" | Excel Programming | |||
Error 1004, "select method of range class failed" | Excel Programming | |||
Runtime Error "1004" Select Method of Range Class Failed | Excel Programming |