Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.vsnet.vstools.office, microsoft.public.excel.programming,microsoft.public.dotnet.framework.interop, microsoft.public.dotnet.languages.csharp
|
|||
|
|||
Using Excel Interop via VS.NET 2005 to create and save a new Excelworksheet.. please help!
Guys,
Sorry for crossing multiple groups but I am at my wits end... Please help! Below is my code in C# (VS.NET 2005.. I have tried every combo I can think of. Every "SaveAs" call results in the strange HRESULT 0x800A03EC error. I have verified that the folder path exists and that "Everyone" has Full Control on it. I have also tried Missing.Value in place of nulls. :( Thanx! J'son CODE: //create initial excel sheet GC.Collect(); //clear out any earlier instances Excel._Application application = new Excel.Application(); application.Visible = false; Excel._Workbook workbook = application.Workbooks.Add(Missing.Value); Excel._Worksheet sheet = (Excel._Worksheet)workbook.ActiveSheet; //format the titles DataColumnCollection columns = results.Tables[0].Columns; for (int i = 0; i < columns.Count; i++) { string rangeHeader = ColumnLetter(i + 1) + "1"; Excel.Range range = (Excel.Range)sheet.get_Range(rangeHeader, rangeHeader); range.Font.Bold = true; range.VerticalAlignment = Excel.XlVAlign.xlVAlignCenter; range.Value2 = columns[i].ColumnName; range.EntireColumn.AutoFit(); } //save the workbook for now -- ERROR HITS HERE! application.ActiveWorkbook.SaveAs(_filePath, Excel.XlFileFormat. xlWorkbookNormal, null, null, false, false, Excel.XlSaveAsAccessMode. xlNoChange, false, false, null, null, null); workbook.Close(null, null, null); application.Quit(); Thanx! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how to save an Excel 2007 on CD, be able to open it using 2005 | Excel Discussion (Misc queries) | |||
Create DLL in Visual Studio 2005 accessible by Excel 2002 | Excel Programming | |||
Cannot create instance of C# COM server compile with VS 2005 | Excel Programming | |||
After Save Event (Interop) | Excel Programming | |||
Using interop.excel to open a workbook, the workbook doesn't ask to save changes. | Excel Programming |