Automating Excel WorkBook With C# Suppress Excel Message Boxes Possible?

  • Thread starter unemotionalhumanoid
  • Start date
U

unemotionalhumanoid

I am writing an application that gets data from excel worksheets, it works
fine for most workbooks but when I open some by using the following code:

_xlApp = new Excel.ApplicationClass();

Excel.Workbook WorkBook1 = _xlApp.Workbooks.Open(FilePath,0,true, 5,"",
"", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, false, false,
false);

Excel produces a message box saying:

Microsoft Office Excel recalculates formulas when opening files last
saved by an earlier version of excel (Yes / NO / Cancel)

Is there any way to suppress these annoying message boxes?

Thank you
 
J

jaf

Hi,
Add _xlApp.Application.DisplayAlerts=Fales beford the workbook open
statement.
And _xlApp.Application.DisplayAlerts=True after to re-enable.
 

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