Re: Saving Excel File

Steve Abaffy <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.winforms
Message-ID <01dd01c770b1$285f8760$791e9620$@biz>
There is no SaveAs Method for the ExcelObjOut.

-----Original Message-----
From: Discussion forum for developers using Windows Forms to build apps and
controls [mailto:[email protected]] On Behalf Of Hugh
Brown
Sent: Tuesday, March 27, 2007 12:53 PM
To: [email protected]
Subject: Re: [DOTNET-WINFORMS] Saving Excel File

Try:
   ExcelObjOut.SaveAs(NewFileName);


Steve Abaffy <[email protected]> wrote: I have the following code

_Application ExcelObjOut = new ApplicationClass();
Workbooks workbooks = ExcelObjOut.Workbooks;
_Workbook Workbook = workbooks.Add(XlWBATemplate.xlWBATWorksheet);
_Worksheet Sheets = (_Worksheet)Workbook.ActiveSheet;
Range Range;
//NewFile name is generated from an OpenDialogBox FileName so the path is
included

NewFileName = FileName.Substring(0,FileName.IndexOf(".")) + Processed.xls";

//Add stuff to NewFile (This works fine)

// This line does not save the new file as NewFileName it asked me to save
Sheet1 opens up a save dialog box and allows me to save the file.
ExcelObjOut.Save(NewFileName);

// Then this line throws an exception that it can't find the NewFileName
file.
ExcelObjOut.Quit();

So the question I guess is how do you save a new Excel file that is being
generated on the fly after you get done putting your values in it?

Thanks
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.