How to open savedialogbox in excel from .net windows form
I have created an a开发者_如何转开发pplication in vb.net from this application i want to open excel file with excel's saveAs option. Is there any way i can do this?
thanx
I am not sure how you can do this prior to Office 2007, but in 07 onwards there is an Application.GetSaveAsFilename() method which pops up a save as dialog.
Something like this might do what you want (in C#):
var app = new Microsoft.Office.Interop.Excel.Application();
app.Visible = true;
var book = app.Workbooks.Open(@"I:\ApplicationsUAT\PriceGrab\PriceCheck.xls");
book.Names.Item("dt").RefersToRange.Value = DateTime.Today.ToOADate();
app.CalculateFull();
object fld = app.GetSaveAsFilename(FileFilter:"Microsoft Office Excel Workbook (*.xls), *.xls");
if (fld is string)
book.SaveAs((string)fld, Microsoft.Office.Interop.Excel.XlFileFormat.xlExcel12);
book.Close(false);
app.Quit();
精彩评论