开发者

ErrorMessage in Excel

i got a urgent problem with the following error, while setting the DisplayAlerts-property of the Excel ApplicationClass to false.

var excel = new Excel.Application();
excel.DisplayAlerts = false;

I get the following error message in the logs:

System.Runtime.InteropServices.COMException (0x800AC472): Exception from H开发者_运维问答RESULT: 0x800AC472
     at Microsoft.Office.Interop.Excel.ApplicationClass.set_DisplayAlerts(Boolean RHS)
     at Service.Dispose()

The following MessageBox is shown

ErrorMessage in Excel

(source: xlam.ch)

Any ideas on this case?

Regards MacX


I think you should call DisplayAlerts on the instance of Excel.Application you're working with. Something like this:

var excel = new Excel.Application();
excel.DisplayAlerts = false;


You'll have to catch that error and re-submit whatever you were inserting into a cell on excel. This is an annoying bug and I have not been able to implement and elegant solution for.

Someone can correct me if I am wrong but I cannot find a way to determine if Excel is in a "suspended" state or not besides catching this exception. It's like an unavoidable race condition where you don't know the result until you know the result. I searched for a way to solve this before giving up and implemented an ugly error checking solution.

Sorry, I hope someone has a better solution for this than me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜