0
我试图从Python运行Excel宏。Python:使用win32com.client.dispatch打开工作簿,取消激活工作簿加载项
我使用这段代码:
import os
import win32com.client
filepath = r"myfilepath"
if os.path.exists(filepath):
xl=win32com.client.Dispatch("Excel.Application")
xl.Workbooks.Open(Filename=filepath)
xl.Application.Run("SendReport")
## xl.Application.Save() # if you want to save then uncomment this line and change delete the ", ReadOnly=1" part from the open function.
xl.Application.Quit() # Comment this out if your excel script closes
del xl
的代码工作正常,但我的工作簿从外接使用自定义VBA函数。当我用这种调度方法打开工作簿时,加载项被禁用,并且功能不再工作。
是否有任何其他方法来打开将使我的加载项处于活动状态的工作簿?