Excel OLE - 当 Excel 嵌入到应用程序中时,.NET COM AddIn 的行为有所不同

发布于 2024-08-07 00:31:05 字数 405 浏览 2 评论 0原文

我有一个 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

战皆罪 2024-08-14 00:31:05

我不得不承认我对 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

明明#如月 2024-08-14 00:31:05

我就这个问题联系了微软专业人士,发现微软现在不鼓励嵌入办公应用程序。有人建议我停止将 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文