Excel OLE - .NET COM AddIn behaves differently when Excel is embedded in an application

烂漫一生 提交于 2019-12-13 00:24:55

问题


I have a .NET (C#) addin that uses a COM Shim dll to load itself into Excel. The addin works fine without any problem when Excel is run normally. The addin displays its own custom toolbar in Excel that is used to execute different commands.

When I embed Excel into another application (e.g. DSOFramer etc), the addin starts behaving strangely. It seems that if I disable a button on its toolbar then it does not get enabled again after setting the Visible property. Also, I get a bunch of "Object reference not set" errors because the Application::Selection object is NULL which never happens when Excel is running normally. Sometimes I also get permission errors when Application::GetAddIns() method is called.

I am not sure what is happening here and I could not find an articles that explains the behavior of Excel COM Addins when Excel is embedded inside other application.


回答1:


I have to admit I don't know much about dSOFramer, but I did run across the following items. I don't know if these help at all.

link text

link text




回答2:


I contacted Microsoft Professional for this issue and found out that Microsoft now discourages embedding office applications. I was suggested to either stop embedding Excel into the application OR use only Excel 2007 that has a Ribbon UI. According to MS, the Ribbon UI does not have these issues.

The problem with the CommandBars is that the negotiation only happens during the OnConnection and no changes can be made afterwards.



来源:https://stackoverflow.com/questions/1510983/excel-ole-net-com-addin-behaves-differently-when-excel-is-embedded-in-an-appl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!