我还看到了其他一些类似的问题,不幸的是,没有一个完全解决了我的问题。我的代码非常广泛,所以不会将所有内容都粘贴到这里。我的python脚本正在运行一个excel和一个宏。它做的很好,但当涉及到保存文件下来,我得到的错误。我在下面展示了我的代码片段。知道发生了什么吗?它偶尔工作良好,并随机停止工作
import win32com.client
import time
from datetime import datetime
def openWorkbook(xlapp, xlfile,upDateLink,openReadOnly,wbVisible):
try:
xlwb = xlapp.Workbooks(xlfile,upDateLink,openReadOnly,wbVisible) # the 2nd is for updatelink, 3rd is for OpenReadOnly
except Exception as e:
try:
print('run function')
xlapp.Workbooks.Open('C:\\blp\\API\\Office Tools\\BloombergUI.xla')
xlapp.RegisterXLL('C:/blp/API/Office Tools/bofaddin.dll')
xlwb = xlapp.Workbooks.Open(xlfile,upDateLink,openReadOnly) # the 2nd is for updatelink, 3rd is for OpenReadOnly
xlapp.Visible = wbVisible
except Exception as e:
print(e)
xlwb = None
return(xlwb)
wb1 = openWorkbook(xlapp, filepath,False,True,wbVisible)
filepathSaveStress = "C:\\Users\\abc\\Downloads\\Projects\\Stress" + extractDate2 + ".xlsm"
print('run CalculateValues')
xlapp.Application.run("CalculateValues")
xlapp.DisplayAlerts = False
if stresstype == 'Stress':
wb1.SaveAs(filepathSaveStress)
else:
wb1.SaveAs(filepathSavePostStress)
不确定它为什么在wb1.SaveAs(filepathSaveStress)
出错
不管是术语还是错误,我得到的都是这个
'bool' object is not callable
目前没有回答
相关问题 更多 >
编程相关推荐