I have a VSTO 2005 SE add-in for excel in which I need to programatically save the document on an event. When I tried workbook.save() to accomplish this the workbook gets saved with its temporary name eg "Book1.xlsx" in My Documents and doesnt pop-up a save as dialogue even with a document which is previously unsaved. I tried this with a word document and there the behaviour was as expected ie. it shows a save-as dialogue for a fresh document and doesn't when the document has been previously saved. Is there a workaround to avoid this behaviour
As a crude workaround I wrote the following code.
string
path = workbook.Path; if (String.IsNullOrEmpty(path)){
SaveFileDialog dialog = new SaveFileDialog();dialog.DefaultExt =
".xlsx"; if (dialog.ShowDialog() == DialogResult.OK){
workbook.SaveAs(dialog.FileName, workbook.FileFormat, missing, missing, false, false, Excel.XlSaveAsAccessMode.xlNoChange, missing,missing, missing, missing, missing);}
}
elseworkbook.
Save();
While this gets the work done, I'd like to add support to save in any of the file-formats supported by excel 2007 and not just .xlsx. Is there any way to achieve this
Thanks
Rishab