Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Charting / October 2006

Tip: Looking for answers? Try searching our database.

Add sheet to workbook

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dorte - 31 Oct 2006 13:12 GMT
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.CurrentCulture = new
System.Globalization.CultureInfo("en-US");

Excel.Workbook book1 = ExcelApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
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
Jon Peltier - 31 Oct 2006 13:42 GMT
Please post in a relevant group.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______

> Hi,
>
[quoted text clipped - 29 lines]
> Thanks,
> Dorte
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.