ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to suppress overwrite prompts (https://www.excelbanter.com/excel-programming/275889-how-suppress-overwrite-prompts.html)

Jack Fox

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



merjet

how to suppress overwrite prompts
 
Try changing:
oEx.AlertBeforeOverwriting = false

To:
oEx.DisplayAlerts = False

HTH,
Merjet




All times are GMT +1. The time now is 04:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com