Closing, Saving question

F

Fritz Hilgemann

Hello,

I really hope I am right here. I am programming an excel client in c#, and I
try to start excel with an empty workbook and then save it with a given
filepath.
Empty workbook seems ok:
object missing = System.Reflection.Missing.Value;

appExcel.Visible = true;

wb = (Workbook)appExcel.Workbooks.Add(missing);

However, when I try to Close(...) or SaveAs(...), excel allways comes up
with the messagebox if I want to override the existing file.

Example:

wb.Close(true,"d:\\Excelsheet.xls",false);

appExcel.Workbooks.Close();

appExcel.Quit();



My question: How can I prevent excel from displaying the messagebox, and
save the file in any case ?

Weired, in the case above, if I answer the messagebox with "no", I get an
exception on the wb.Close() call.



Thank you for any hints

Fritz
 
B

Barb Reinhardt

In VBA, you can use

WB.Close SaveChanges:= True

Is there something in c# that's similar?
 
F

Fritz Hilgemann

Yes, but appearently it does not prevent the messagebox. In the code line
wb.Close(true,"d:\\Excelsheet.xls",false); (see orig. message)
the first parameter is named "SaveChanges".

Fritz
 
F

Fritz Hilgemann

Uuh, I just got it, although it is a little weired:
appExl.DisplayAlerts = false;

Thanks anyway!
Fritz
 

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