下面是一行684碼屬性錯誤,當設法保存Excel文件的win32
try:
xlBook.SaveAs("%s/ContingencyFile.xlsx" %(os.getcwd()))
xlApp.DisplayAlerts = True
except:
xlApp.xlBook.Close
xlBook.SaveAs("%s/ContingencyFile.xlsx" %(os.getcwd()))
xlApp.DisplayAlerts = True
這是我遇到運行我的程序,而錯誤 -
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python27\lib\lib-tk\Tkinter.py", line 1410, in __call__
return self.func(*args)
File "H:\proj4\combine.py", line 684, in ProcessNewFile
xlApp.xlBook.Close
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 516,
in__getattr__
raise AttributeError("%s.%s" % (self._username_, attr))
AttributeError: Excel.Application.xlBook
我怎麼能擺脫錯誤?
如果'xlBook.SaveAs'是正確的,那麼'xlApp.xlBook.Close'應該是'xlBook.Close' –