0

Last week I created some simple code to read in an excel where I want to save the images from:

excel = win32com.client.Dispatch("Excel.Application")
workbook = excel.Workbooks.Open('Excel1.xlsx')

However when I want to use it now I suddenly get the following error, while it was working last week:

pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft Excel', u"Sorry, we couldn't find Excel1.xlsx. Is it possible it was moved, renamed or deleted?", u'xlmain11.chm', 0, -2146827284), None)

The Excel file was not removed and is still in the same folder as the script. Previously it opened the file but now not anymore. How is this possible?

When I use workbook = excel.ActiveWorkbook instead of workbook = excel.Workbooks.Open('Excel1.xlsx') it works, so the problem is in opening the file I think.

Fringo
  • 335
  • 1
  • 3
  • 17

0 Answers0