Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
import win32com import win32com.client as win32 xl = win32.gencache.EnsureDisplatch('Excel.Application')
这会启动 Excel,但无论出于何种原因,都没有加载任何插件。
如果 Excel 已经加载,插件将保持加载状态并且可以访问。
请指教。
上下文:我正在从使用专有插件进行调用的工作表中抓取数据。如果插件没有加载,我需要抓取的所有单元格都会抛出错误。
xl = win32.gencache.EnsureDispatch('Excel.Application')
这里的错别字。
也许您可以添加代码以在宏中访问您的插件,然后从 Python 自动化宏。
xl.Run("Book1.xls!Macro1")