Workbooks.Open fails randomly throws an exception Code:
def logToXLS(fileNameXLS,worksheetNum,row,col,data): import win32com.client fileName=fileNameXLS # Xls File name to be updated path=os.getcwd() filePath=os.path.join(os.getcwd(),fileNameXLS) xl = win32com.client.Dispatch("Excel.Application") try : wb = xl.Workbooks.Open(filePath) except: print "Failed to open spreadsheet for the path %s" %(filePath) sh = wb.worksheets(worksheetNum) sh.Cells(row,col).Value = data wb.Save() wb.Close() calling logToXLS() occasionally throws the mentioned error at xl.Workbooks.Open(filePath) File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", > line 496, in > __getattr__ > raise AttributeError, "%s.%s" % (self._username_, attr) > AttributeError: Excel.Application.Workbooks 1)is there any limitation on number of characters on filepath? 2)How this issue can be overcome?
_______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32