Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Why does Range.Group() method crash after 7 calls?

Hello,
I have a problem with Microsoft.Office.Interop.Excel.Range.Group()
method.
The problem is that I can call this method only 7 times, before it
throws me an exception.
I don't understand quite well why this happens, and for witch
documents this affirmation is valid, but the problem exists, probably,
for a large files.
For example, if you save this file - http://serhio.atspace.com/ExcelData.xls
on the drive C, and executes the following code:

Code Snippet
static void Main(string[] args)
{
Microsoft.Office.Interop.Excel.Application excelApp = new
ApplicationClass();
excelApp.Visible = true; // Makes Excel visible to the
user.

string workbookPath = @"C:\ExcelData.xls"; // Add your
own path here
// The following code opens an existing workbook
Workbook excelWorkbook =
excelApp.Workbooks.Open(workbookPath, 0,
false, 5, "", "", false, XlPlatform.xlWindows, "",
true,
false, 0, true, false, false);

// The following gets the first Woorksheet
Worksheet worksheet = excelWorkbook.Worksheets.get_Item(1)
as Worksheet;
worksheet.Outline.SummaryRow =
XlSummaryRow.xlSummaryAbove;

Range aRange;
int groupCounter = 0;
try
{
for (int i = 10; i < 450; i = i + 11)
{
aRange =
worksheet.get_Range(string.Format("C{0}:C{1}", i, i + 10),
Missing.Value);
aRange.Group(Missing.Value, Missing.Value,
Missing.Value, Missing.Value);
groupCounter++;
}
}
catch (Exception ex)
{
throw ex;
}
}

when I have groupCounter == 7, I get a
[System.Runtime.InteropServices.COMException] = {"Group method of
Range class failed"}

You can skip some groups, in order to use different lines to group,
but anyway, the 7-th call of Group method crashes the application.

Is there somebody qho can explain this behavior, and how can I resolve
this issue?

Thanks a lot
/sergiu

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default Why does Range.Group() method crash after 7 calls?

see reply to your other post

--

Regards,
Nigel




"serhio" wrote in message
...
Hello,
I have a problem with Microsoft.Office.Interop.Excel.Range.Group()
method.
The problem is that I can call this method only 7 times, before it
throws me an exception.
I don't understand quite well why this happens, and for witch
documents this affirmation is valid, but the problem exists, probably,
for a large files.
For example, if you save this file -
http://serhio.atspace.com/ExcelData.xls
on the drive C, and executes the following code:

Code Snippet
static void Main(string[] args)
{
Microsoft.Office.Interop.Excel.Application excelApp = new
ApplicationClass();
excelApp.Visible = true; // Makes Excel visible to the
user.

string workbookPath = @"C:\ExcelData.xls"; // Add your
own path here
// The following code opens an existing workbook
Workbook excelWorkbook =
excelApp.Workbooks.Open(workbookPath, 0,
false, 5, "", "", false, XlPlatform.xlWindows, "",
true,
false, 0, true, false, false);

// The following gets the first Woorksheet
Worksheet worksheet = excelWorkbook.Worksheets.get_Item(1)
as Worksheet;
worksheet.Outline.SummaryRow =
XlSummaryRow.xlSummaryAbove;

Range aRange;
int groupCounter = 0;
try
{
for (int i = 10; i < 450; i = i + 11)
{
aRange =
worksheet.get_Range(string.Format("C{0}:C{1}", i, i + 10),
Missing.Value);
aRange.Group(Missing.Value, Missing.Value,
Missing.Value, Missing.Value);
groupCounter++;
}
}
catch (Exception ex)
{
throw ex;
}
}

when I have groupCounter == 7, I get a
[System.Runtime.InteropServices.COMException] = {"Group method of
Range class failed"}

You can skip some groups, in order to use different lines to group,
but anyway, the 7-th call of Group method crashes the application.

Is there somebody qho can explain this behavior, and how can I resolve
this issue?

Thanks a lot
/sergiu


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
Constructing Range Name calls with Concatenate CellShocked Excel Worksheet Functions 4 October 26th 11 11:06 AM
Range.Group() method fails after 7 calls serhio[_2_] Excel Programming 0 April 24th 08 06:39 PM
group method - is there a collection jimm Excel Programming 1 February 26th 06 05:04 AM
Group Method failed in macro Ivan Excel Programming 0 September 3rd 05 06:07 AM
Tracing method calls Jamie Martin[_2_] Excel Programming 1 November 7th 03 01:31 AM


All times are GMT +1. The time now is 05:28 PM.

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"