Using interop.excel to open a workbook, the workbook doesn't ask to save changes.

M

milmans

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();
 
P

Peter T

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top