Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default "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
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
"Select method of Range class failed" Error Ayo Excel Discussion (Misc queries) 3 September 2nd 08 07:58 PM
Run-time error "1004" Select method of range class failed Tallan Excel Discussion (Misc queries) 3 March 7th 07 05:22 PM
VBA error 1004 "Select method of Range class failed" Matt J Excel Programming 6 July 3rd 04 10:05 PM
Error 1004, "select method of range class failed" paritoshmehta[_11_] Excel Programming 3 May 6th 04 10:09 PM
Runtime Error "1004" Select Method of Range Class Failed Stephen[_7_] Excel Programming 4 April 10th 04 06:28 AM


All times are GMT +1. The time now is 01:17 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"