如何使用 Python win32com 中的所有默认加载项运行 excel
import win32com
import win32com.client as win32
xl = win32.gencache.EnsureDisplatch('Excel.Application')
这会启动 Excel,但无论出于何种原因,都不会加载任何插件。
如果 Excel 已加载,则插件将保持加载状态并可供访问。
请指教。
上下文:我正在从使用专有插件进行调用的工作表中抓取数据。如果插件未加载,我需要抓取的所有单元格都会抛出错误。
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.
If Excel was already loaded, the plugins will stay loaded and be accessible.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许您可以添加代码来访问宏中的插件,然后从 Python 自动化宏。
Perhaps you can add the code to access your plugin in a macro and then automate the macro from Python.
xl = win32.gencache.EnsureDisplatch('Excel.Application')
此处有拼写错误。
xl = win32.gencache.EnsureDispatch('Excel.Application')
xl = win32.gencache.EnsureDisplatch('Excel.Application')
typos here.
xl = win32.gencache.EnsureDispatch('Excel.Application')