在 python 中使用 excel 插件的问题

发布于 2025-01-06 09:20:03 字数 572 浏览 2 评论 0原文

我正在尝试使用 python 和 win32com 将 excel 工作簿加载到我打开的 excel 实例中,该实例具有活动的插件

我用来打开文件的代码是这样的。

excel=win32com.client.Dispatch("Excel.Application")
source = excel.Workbooks.Open('test.xlsm')

问题是,这实际上是在没有激活插件的情况下打开一个单独的 Excel 实例。

我尝试打开该插件文件,然后打开工作簿,如下所示。

excel=win32com.client.Dispatch("Excel.Application")
addin = excel.Workbooks.Open('addin.xla')
source = excel.Workbooks.Open('test.xlsm')

但是当我尝试使用插件时,我收到与此类似的错误。

无法运行宏“sbex.xla!runQuery”

任何想法都会有帮助。

I am trying to use python and win32com to load an excel workbook into an instance of excel that I had opened that has an addin active

The code I'm using to open the file is this.

excel=win32com.client.Dispatch("Excel.Application")
source = excel.Workbooks.Open('test.xlsm')

The problem is that this is actually opening a separate instance of excel without the addin active.

I have tried opening that addin file and then the workbook like this.

excel=win32com.client.Dispatch("Excel.Application")
addin = excel.Workbooks.Open('addin.xla')
source = excel.Workbooks.Open('test.xlsm')

but when I try and use the addin I get an error similar to this.

Can't run macro "sbex.xla!runQuery"

Any ideas would be helpful.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文