当将Excel嵌入应用程序中时,Excel OLE-.NET COM加载项的行为会有所不同 [英] Excel OLE - .NET COM AddIn behaves differently when Excel is embedded in an application

查看:172
本文介绍了当将Excel嵌入应用程序中时,Excel OLE-.NET COM加载项的行为会有所不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.NET(C#)加载项,它使用COM Shim dll将自身加载到Excel中.正常运行Excel时,外接程序工作正常,没有任何问题.该插件在Excel中显示其自己的自定义工具栏,该工具栏用于执行不同的命令.

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.

当我将Excel嵌入到另一个应用程序(例如DSOFramer等)中时,加载项开始表现异常.看来,如果我禁用其工具栏上的按钮,则在设置Visible属性后不会再次启用它. 另外,我收到一堆未设置对象引用"错误,因为Application :: Selection对象为NULL,这在Excel正常运行时永远不会发生.有时,在调用Application :: GetAddIns()方法时也会出现权限错误.

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.

我不确定这里发生了什么,我找不到找到解释将Excel嵌入其他应用程序中时Excel COM加载项行为的文章.

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.

推荐答案

我就此问题与Microsoft Professional联系,发现Microsoft现在不鼓励嵌入Office应用程序.建议我停止将Excel嵌入到应用程序中,或者仅使用具有功能区UI的Excel 2007.据MS称,Ribbon UI没有这些问题.

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.

CommandBars的问题在于,协商仅发生在OnConnection期间,并且此后无法进行任何更改.

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

这篇关于当将Excel嵌入应用程序中时,Excel OLE-.NET COM加载项的行为会有所不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆