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.

4
  • check this - stackoverflow.com/a/39880844/5585424 Commented Jun 11, 2018 at 7:48
  • That is not a solution to my problem unfortunately. With that script I get the same error. Commented Jun 11, 2018 at 8:35
  • Having the same problem, did you ever find a solution? I uninstalled and reinstalled pywin32, cleared my roaming Excel cache, changed directories, re-downloaded the file. Same error Commented May 29, 2020 at 18:47
  • Did you ever find out what the issue here was? Commented Oct 20, 2021 at 14:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.