![]() |
Using interop.excel to open a workbook, the workbook doesn't ask to save changes.
I'm using C# and the Interop.Excel assembly to programatically open an
..xls file, make some changes, then save the changes. The code works fine, the changes are saved, etc. But when I use excel to open the file, then make some changes manually, Excel no longer prompts me to save my changes - it just closes the file without saving. here is the C# code that I'm running. Before I run this code, junk.xls works normally. It prompts for changes, etc. After I run this code, junk.xls no longer prompts me to save any changes that I've made. This code doesn't even change or save junk.xls (as far as I can tell). Can anyone help? Excel.ApplicationClass app = new Excel.ApplicationClass(); Excel.Workbook wb2 = (Excel.Workbook)app.Workbooks.Open( "c:\\temp\\junk2.xls", false, false, Type.Missing, Type.Missing, Type.Missing, true, Type.Missing, Type.Missing, true, false, Type.Missing, false, Type.Missing, true); wb2.Close(false, Type.Missing, Type.Missing); app.Quit(); |
Using interop.excel to open a workbook, the workbook doesn't ask to save changes.
I don't know C#, but as a guess maybe one of those false's is doing the VBA
equivalent of Application.DisplayAlerts = False This is an application level setting that needs to be reset to True. Regards, Peter T wrote in message oups.com... I'm using C# and the Interop.Excel assembly to programatically open an .xls file, make some changes, then save the changes. The code works fine, the changes are saved, etc. But when I use excel to open the file, then make some changes manually, Excel no longer prompts me to save my changes - it just closes the file without saving. here is the C# code that I'm running. Before I run this code, junk.xls works normally. It prompts for changes, etc. After I run this code, junk.xls no longer prompts me to save any changes that I've made. This code doesn't even change or save junk.xls (as far as I can tell). Can anyone help? Excel.ApplicationClass app = new Excel.ApplicationClass(); Excel.Workbook wb2 = (Excel.Workbook)app.Workbooks.Open( "c:\\temp\\junk2.xls", false, false, Type.Missing, Type.Missing, Type.Missing, true, Type.Missing, Type.Missing, true, false, Type.Missing, false, Type.Missing, true); wb2.Close(false, Type.Missing, Type.Missing); app.Quit(); |
All times are GMT +1. The time now is 08:44 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com