Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Adding worksheets

Hello, I guess this is kind of basic stuff, but I would be very
pleased if you could help me anyway. Im trying to add a number of
sheets to a workbook in vsto (c#). I use a list to add several sheets.
the interesting code is pretty much:

List<Excel.Worksheet ws;

ws = new List<Excel.Worksheet();
for (int i = 0; i <= theend; i++)
{

ws.Add((Excel.Worksheet)Globals.ThisWorkbook.Works heets.Add(missing,
missing, missing, missing));
//a lot of code after this:

}

This work the first time in the loop, the other time though I get an
ArgumentOutOfRangeException when it hits any of the ws objects. I may
have done this completely wrong, but Im new with this so have patience
plz ; )

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Adding worksheets

new is object oriented code to create a new class (object). The new
sttatement assigns memory space for the class. You can't add moe than one
item to the object because there isn't enough memory. There isn't enough
code to tell what you are doing to give suggestions.

" wrote:

Hello, I guess this is kind of basic stuff, but I would be very
pleased if you could help me anyway. Im trying to add a number of
sheets to a workbook in vsto (c#). I use a list to add several sheets.
the interesting code is pretty much:

List<Excel.Worksheet ws;

ws = new List<Excel.Worksheet();
for (int i = 0; i <= theend; i++)
{

ws.Add((Excel.Worksheet)Globals.ThisWorkbook.Works heets.Add(missing,
missing, missing, missing));
//a lot of code after this:

}

This work the first time in the loop, the other time though I get an
ArgumentOutOfRangeException when it hits any of the ws objects. I may
have done this completely wrong, but Im new with this so have patience
plz ; )


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
Adding Across WorkSheets computerangel Excel Worksheet Functions 0 July 8th 08 06:08 PM
adding worksheets sorab Excel Discussion (Misc queries) 1 September 5th 06 02:41 PM
adding worksheets together Gary Excel Discussion (Misc queries) 1 June 27th 05 08:26 PM
Adding worksheets mike clay Excel Programming 1 April 28th 04 09:38 AM
Adding Worksheets Peter[_33_] Excel Programming 6 January 16th 04 04:54 PM


All times are GMT +1. The time now is 09:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"