Question

I have a plugin which populates an array on an Excel spreadsheet. If the submitted parameters are wrong, it writes an error message in one cell instead.

Unfortunately, when the plugin displays the error message, Excel effectively disables the plugin. As a result, the next time I reopen the spreadsheet, I cannot refresh a previously correctly populated array - all the cells are filled with #NAME?. Also I cannot define a new array to populated via any function from my plugin - the whole category of functions defined in the plugin is not available.

However, when I go to File -> Options -> Add-Ins, the plugin is still listed as active.

I still can unregister the plugin via Add-Ins -> Manage Excel Add-Ins, and then register it again. This restores functionality.

Is there a way to make sure Excel does not automatically disable my plugin?

Was it helpful?

Solution

Excel will disable the plugin if it throws an exception, either a C++ exception, C# exception or an SEH exception.

  • That's because they are not supposed to do that, which means that something has gone wrong.
  • When something has gone wrong with a computer program, you cannot be sure it is doing what it is supposed to do - it could be trashing all of your data, or being a security risk.
  • Excel responds to this by stopping it from doing anything

Don't throw exceptions. Use the documented method to return error values.

You don't say what type of plugin - the method is different for each.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top