Help - Excel Automation: Turning off all dialog boxes (prompts).

P

poochi

Hi,

I have written an excel wrapper class in C#. Excel automation
components are used to read the excel file in my wrapper class. Now the
problem is, I get a dialog box with the following message in one of the
files that is being processed (when it is opened in Excel application
by double clicking on the file in windows explorer).

"Name conflicts with existing module, project, or object library"

ok. It tells me some VBA reference is wrong in the Excel file. But I
couldn't bypass this dialog programmatically. This wrapper class is
used in a non-interactive environment. Here is the sample code..

Excel.Application excelApplication = null;
Excel.Workbooks workBooks = null;
Excel.Workbook workBook = null;
string fileName = @"c:\temp\myexcelfile.xls";
object missingValue = Missing.Value;

try
{
excelApplication = new Excel.ApplicationClass();

// turn-off all interactive features
excelApplication.Visible = false;
excelApplication.Interactive = false;
excelApplication.DisplayAlerts = false;
excelApplication.DisplayInfoWindow = false;
excelApplication.ScreenUpdating = false;
excelApplication.AlertBeforeOverwriting = false;
excelApplication.AskToUpdateLinks = false;

// Open workbook
workBooks = excelApplication.Workbooks;
workBook = workBooks.Open(fileName, false, true, missingValue,
missingValue, missingValue,
missingValue, missingValue, missingValue, false, false,
missingValue, false, missingValue, true);

...........
...........
}
catch(Exception e)
{
System.Console.WriteLine(e.Message);
}
finally
{

.......
}

The application hangs at "Open" method and waiting for the dialog to be
closed. Is there anyway to turn off all the dialog boxes? As far as I
can see, I handled all the interactive properties in my code. But
still, the open method hangs.

Any help would be appriciated.

Thanks
 
Joined
Oct 3, 2006
Messages
1
Reaction score
0
Hello poochi,

Im having the same problem, what im doing is based on a excel template i create a new one, all fine until i reach:

"xlBook = xlApp.Workbooks.Open(GrelhaCalculoFilename, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value);"

where it hangs and throws an exception about 15 minutes later. Yeah i waited all that long just to see it giving the stupid error.

All the premissions are given to the user, administrators and the ASP.NET Machine Account etc, on the folder file and even on the Component Services i gaved the proper permissions to the DCOM Config/Microsoft Excel Application, after all this permissions it still hangs, if u solved ur problem plz post it here.
And yes i have added the @ to the biginig of the file path the problem is much more complicated as far as i can tell.

Thank you in advance

Luis Pinto
Programmer Analist
Bytecode Technologies Solutions
 
Last edited:

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