C# COM in Excel: Avoid using Marshal

T

Torben Laursen

I often get a "Operation unavailable (Exception from HRESULT: 0x800401E3
(MK_E_UNAVAILABLE))"
Error in Excel when I try to call my UDF in a save sheet.

If I waite a few seconds the error goes away and everything works fine.

The error comes from this line of code:
App = (MSExcel.Application)Marshal.GetActiveObject("Excel.Application");

Where App is defined as

private MSExcel.Application App;

I read that I get a reference to Excel in the OnConnection function inside
the Connect class.

But how do I use that reference inside my UDF's?

Torben
 

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