Excel OLE - 当 Excel 嵌入到应用程序中时,.NET COM AddIn 的行为有所不同
我有一个 .NET (C#) 插件,它使用 COM Shim dll 将自身加载到 Excel 中。当Excel正常运行时,该插件工作正常,没有任何问题。该插件在 Excel 中显示其自己的自定义工具栏,用于执行不同的命令。
当我将 Excel 嵌入另一个应用程序(例如 DSOFramer 等)时,插件开始表现奇怪。似乎如果我禁用工具栏上的按钮,那么在设置 Visible 属性后它不会再次启用。 另外,我收到一堆“对象引用未设置”错误,因为 Application::Selection 对象为 NULL,当 Excel 正常运行时,这种情况永远不会发生。有时,当调用 Application::GetAddIns() 方法时,我也会遇到权限错误。
我不确定这里发生了什么,也找不到解释当 Excel 嵌入其他应用程序时 Excel COM 插件的行为的文章。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不得不承认我对 dSOFramer 了解不多,但我确实遇到过以下项目。我不知道这些是否有帮助。
链接文本
链接文本
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
我就这个问题联系了微软专业人士,发现微软现在不鼓励嵌入办公应用程序。有人建议我停止将 Excel 嵌入到应用程序中,或者仅使用具有功能区 UI 的 Excel 2007。根据 MS 的说法,Ribbon UI 不存在这些问题。
CommandBar 的问题是协商仅在 OnConnection 期间发生,之后无法进行任何更改。
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.