I have the Excel HRESULT code 0x800AC472 as VBA_E_IGNORE
, which indicates that Excel has 'suspended the object browser'.
Under certain circumstances Excel will reject all incoming COM requests. Two cases where this happens are where the user
- is busy editing a formula, or
- presses down the mouse button on the Excel sheet.
There might well be other cases - for example I'm not sure what the error code is when Excel is busy calculating.
If you are doing COM automation to talk to an Excel instance that is interactively being used, then any COM call you make to Excel might return this error. One approach I take with Excel-DNA (where the interop always happens from an add-in inside the Excel process) is to attempt to call Application.Run(...) to run a macro in the add-in. Once the Application.Run call succeeds, the macro will run on the main Excel thread in a context where the COM requests won't fail due to Excel suspending the COM calls.
Some other COM errors you can expect from Excel are:
const uint RPC_E_SERVERCALL_RETRYLATER = 0x8001010A;
const uint RPC_E_CALL_REJECTED = 0x80010001; // Not sure when we get this one?
// Maybe when trying to get the Application object from another thread,
// triggered by a ribbon handler, while Excel is editing a cell.
const uint VBA_E_IGNORE = 0x800AC472; // Excel has suspended the object browser
const uint NAME_NOT_FOUND = 0x800A03EC; // When called from the main thread, but Excel is busy anyway.