473,396 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

[Excel] 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:
(see herea formatted variant of this post:
http://forums.microsoft.com/Forums/S...36692&SiteID=1
)

________________________________________________

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;
}
}
________________________________________________

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

Thanks a lot
/sergiu
Jun 27 '08 #1
0 1679

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
17
by: Ange T | last post by:
Hi there, I'm having pain with the VB behind an Access form. The form is used to create reports in Excel based on the details entered in the form. This has always worked without error on my...
0
by: ImraneA | last post by:
Hi there Many thanks to those people who contributed to this group, helped me greatly. Enclose, my code, hope it helps others :- Public Function Export_Excel_9(tbx1 As Variant, tbx2 As...
3
by: Carlos Magalhaes | last post by:
Hey All, I am doing some excel automation using the excel COM. I can do most of the functions and its working well until I come across a formula. I can run a formula and insert the formula...
1
by: Vanajakshi Pidatala | last post by:
Hello, I am trying to show data in dataset in to an excel sheet(ASP.NET/VB.NET). I AM DOING THIS ON SERVER(IIS SERVER) WHICH HAS EXCEL VERSION 9. I COULD ADD REFERENCE TO EXCEL VERSION 9 AND...
7
by: Alan Roberts | last post by:
Can someone please explain the following for me... I am trying to link to a .NET DLL from Excel. Excel needs to pass a reference to itself to the DLL and then the DLL needs to perform some work...
18
by: Frank M. Walter | last post by:
Hello, I have made an small AddIn with udf for excel 2003. I use vs2003. The point of view is the function __T() I call it in excel sheet writing =__T() I am not able to set a value to a...
9
by: Doug Glancy | last post by:
I got the following code from Francesco Balena's site, for disposing of Com objects: Sub SetNothing(Of T)(ByRef obj As T) ' Dispose of the object if possible If obj IsNot Nothing AndAlso...
3
by: Ray | last post by:
Hi, I'm working on something with mysql and excel. I'm using python and win32com. All major function works, But I have two problems: 1. the output need to do "auto fit" to make it readable. ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.