how to suppress overwrite prompts

  • Thread starter Thread starter Jack Fox
  • Start date Start date
J

Jack Fox

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();
 
Try changing:
oEx.AlertBeforeOverwriting = false

To:
oEx.DisplayAlerts = False

HTH,
Merjet
 
Back
Top