I'm busy with an application that manipulates excel data using an C# application.
xlApp = new Excel.Application();
xlWorkbook = xlApp.Workbooks.Open(ConString, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
xlWorksheet = (Excel.Worksheet)xlWorkbook.Worksheets.get_Item(1);
Up until this point, I've saved the workbook by simply saying "xlApp.Quit" this would bring up the standard, "Would you like to save your changes" dialog you get from any Microsoft office product.
However I was having an issue with the workbooks data that was being saved, so I was told to use the Workbook.Save method. It now saves the correct data but I cannot specify the filename/location.
I read about the .SaveCopyAs method, I'm using a save file dialog to provide the filename/location, but when I push save and close the application there is no file to be found.
This is the Savefile method.
private void SaveFile()
{
using (SaveFileDialog Save = new SaveFileDialog())
{
Save.Filter = "Excel Files (*.xlsx)|*.xlsx";
Save.InitialDirectory = "C:";
Save.Title = "Save";
if (Save.ShowDialog() == DialogResult.OK)
{
// Using .SaveCopyAs doesnt save at all
xlWorkbook.SaveCopyAs(saveFileDialog1.FileName);
xlWorkbook.Saved = true;
//Using .Save saves the file, but i cannot specify the location/File name
//xlWorkbook.Save();
xlApp.Quit();
ReleaseObject(xlWorksheet);
ReleaseObject(xlWorkbook);
ReleaseObject(xlApp);
}
}
}
Not sure if this is relevant but here is my ReleaseObject method.
private void ReleaseObject(object obj)
{
try
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
obj = null;
}
catch(Exception ex)
{
obj = null;
MessageBox.Show("Unable to release the object " + ex.ToString());
}
finally
{
GC.Collect();
}
}
I've seen alot of people saying their SaveCopyAs method isn't saving either and that's been due to them not giving the file a name/extension. This was the first thing I checked. This interop stuff is new to me, so please forgive any errors.
Thank you

SaveAsmethod (msdn.microsoft.com/en-us/library/…)? - Jon Davies