COM timeout Excel

Magne 126 Reputation points
2024-04-24T07:13:01.6266667+00:00

Microsoft 365 Excel version 2403.

C# application (WPF on .Net 8) using excel COM interop ("automation") which adds a menu in the Excel application and setsup a click handler (in WPF).

All works normally just fine, but when debugging and say dwelling a couple of minutes (1.5 to be more specific) at a breakpoint in the click handler code, Excel pops up a Ok/Cancel dialogbox stating "Microsoft excel is waiting for another application to complete an OLE action".

if I continue my code with this box still not Ok'ed or Cancelled (which is quite easily happening), the next call to Excel, e.g. Microsoft.Office.Interop.Excel.Application.ScreenUpdating = false; this call throws a COMException (0x800AC472).

If the dialog was closed before proceeding handler code all is fine.

This seems to happen with "all" calls to Excel while dialogbox is open (Ok, I haven't tested with all calls of course, but some).

This upsets my debugging session and I would like Excel to not behave like this, at least something which could be compiled only when debug mode.

Anyone have some hints?

Microsoft 365 and Office Development Other
Microsoft 365 and Office Excel For business Windows
Developer technologies C#
{count} votes

1 answer

Sort by: Most helpful
  1. RLWA32 49,536 Reputation points
    2024-04-26T09:48:56.1566667+00:00

    What you describe is ordinary behavior for a COM Server that is using a message filter to control concurrency.

    Although I don't recommend doing this you could use VBA to call the CoRegisterMessageFilter function to remove Excel's filter which is responsible for putting up the dialog.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.