View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jack Fox Jack Fox is offline
external usenet poster
 
Posts: 1
Default how to suppress overwrite prompts

I have written a C# program to process a large number (1,500) Excel files.
Some of these files are in version 4.0, so I get the following prompt which
stops processing until I manually respond:

"(file name) is a Microsoft Excel 4.0 Worksheet. Do you want to overwrite
with the latest Excel format?"

I always want to overwrite, and I do not want to see this prompt. What can I
do?

Here is the critical code:

Excel.ApplicationClass oEx = new Excel.ApplicationClass();
Excel.Worksheet oWS = (Excel.Worksheet) oEx.Workbooks[1].Worksheets[1];
Excel.Range oRange = (Excel.Range) oWS.Cells;

//...do processing

oEx.AlertBeforeOverwriting = false; //I thought
this property would do the job, but apparently not
oEx.PromptForSummaryInfo = false;
oEx.Workbooks[1].Close(Excel.XlSaveAction.xlSaveChanges, Missing.Value,
Missing.Value);
oEx.Workbooks.Close();