LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 3
Default Add sheet to workbook

Hi,

In a .net console application in C#, I need to create excel files, workbooks
and add sheets to the workbook.
I have added a reference to Microsoft Excel 10.0 object library.

But I get a COM exception when I try to add a sheet to the workbook. Here is
my code:

Excel.Application ExcelApp = new Application();

// bug work around, due to local settings different than English version of
Excel
System.Threading.Thread.CurrentThread.CurrentCultu re = new
System.Globalization.CultureInfo("en-US");

Excel.Workbook book1 = ExcelApp.Workbooks.Add(XlWBATemplate.xlWBATWorkshe et);
book1.Sheets.Add(null, book1.Sheets[1], 1, XlSheetType.xlWorksheet);

The last line of code generates the following error:
Exception from HRESULT: 0x800A03EC
error code:-2146827284

Could anyone tell me how I can add sheets to the workbook without getting an
error?

Thanks,
Dorte

 
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
macro unouwanme Excel Discussion (Misc queries) 9 August 31st 06 09:38 PM
Sum up columns in different sheet with error check zeyneddine Excel Discussion (Misc queries) 13 July 10th 06 01:21 PM
Search open sheets in workbook and insert into open sheet punx77 Excel Discussion (Misc queries) 0 March 6th 06 05:07 PM
Use Sheet CodeNames to Select Sheet in Different Workbook Randy Excel Discussion (Misc queries) 1 June 10th 05 12:17 AM
Does excel recognise names rather than cells? Sue Excel Worksheet Functions 9 May 22nd 05 04:51 AM


All times are GMT +1. The time now is 11:51 PM.

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"