如何:具有多个具有动态属性的工作簿级功能区项目的 Excel 功能区?

发布于 2024-08-15 18:40:36 字数 534 浏览 3 评论 0原文

我正在尝试制定一个解决方案来跨工作簿共享我的大部分 VBA 代码库。这涉及创建一个包含共享模块和共享模块的 .xlam 文件。类(+各自的工厂)。

我愿意使用 Office 2007 出色的 RibbonUI,并让 .xlam 文件声明一个自定义选项卡(为了方便起见,让我们将其称为 MyTab)。我需要 MyTab 仅在用户具有特定权限(我通过 VBA 管理)时显示某些元素。

除此之外,我希望我的其他工作簿能够向 MyTab 添加内容,其中也可能包含动态元素(使用 VBA)。

我面临的问题是,每当我遇到工作簿引用 AddIn.xlam 并声明动态功能区元素的情况时,Excel 都会尝试一次刷新所有内容,从而在两个单独的文件中调用 VBA 代码线程(我猜),最终失败(因为 VBA 在 Excel 中是单线程强制的),并生成空白对话框,上面只写有“400”以及两个按钮“确定”和“帮助”。

有人有如何最好地解决这个问题的经验吗?

I am trying to work out a solution to share most of my VBA codebase across workbooks. This involves creating a .xlam file that would contain the shared modules & classes (+ their respective factories).

I'm willing to use Office 2007's wonderful RibbonUI, and have that .xlam file declare a custom tab (Let us call it MyTab for the sake of the argument). I need MyTab to only display some elements if the user has specific permissions (which I manage through VBA).

Besides that, I want my other workbooks to be able to add stuff into MyTab, which may also have dynamic elements (that use VBA).

The issue I'm facing is that whenever I get in the case where a workbook references the AddIn.xlam and declares dynamic ribbon elements, Excel tries to refresh all at once, thus calling VBA code in two separate threads (I guess), which eventually fails (because VBA is single-thread-forced in Excel), and generates blank dialog boxes with just "400" written on those and two buttons "OK" and "Help".

Has someone got experience on how to best tackle this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

戏舞 2024-08-22 18:40:36

您是否尝试过设置Application.MultiThreadedCalculation = False

我相信这会解决你的问题。

Have you tried setting Application.MultiThreadedCalculation = False.

I believe that will correct your issue.

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