简体   繁体   English

如何使用 Python win32com 中的所有默认加载项运行 excel

[英]How do I run excel using all the default add-ins from Python win32com

import win32com
import win32com.client as win32

xl = win32.gencache.EnsureDisplatch('Excel.Application')

This fires up Excel, but for whatever reason none of the plugins load.这会启动 Excel,但无论出于何种原因,都没有加载任何插件。

If Excel was already loaded, the plugins will stay loaded and be accessible.如果 Excel 已经加载,插件将保持加载状态并且可以访问。

Please advise.请指教。

Context: I'm scraping data from a worksheet that makes calls using a proprietary plugin.上下文:我正在从使用专有插件进行调用的工作表中抓取数据。 If the plugin doesn't load, all the cells I need to scrape just throw errors.如果插件没有加载,我需要抓取的所有单元格都会抛出错误。

xl = win32.gencache.EnsureDisplatch('Excel.Application') xl = win32.gencache.EnsureDispatch('Excel.Application')

typos here.这里有错别字。

xl = win32.gencache.EnsureDispatch('Excel.Application') xl = win32.gencache.EnsureDispatch('Excel.Application')

Perhaps you can add the code to access your plugin in a macro and then automate the macro from Python.也许您可以添加代码以在宏中访问您的插件,然后从 Python 自动执行宏。

xl.Run("Book1.xls!Macro1")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM