[python-win32] pywin can not access excel file

Tamara Abugharbieh Tamara.Abugharbieh at Realsoft-me.com
Sun Dec 12 03:32:01 EST 2021


Hi,

We are using winpy32 to automate excel applications using python. The python script will be used by users with no administrator privileges, and in this case, we are getting the following error:
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft Excel', \"Microsoft Excel cannot access the file 'C:\\\\App\\\\Backend\\\\public\\\\MSB_2021\\\\11\\\\SYB_10_7_V1.xlsx'. There are several possible reasons: The file name or path does not exist. The file is being used by another program. The workbook you are trying to save has the same name as a currently open workbook.\", 'xlmain11.chm', 0, -2146827284)

Things to note:

  1.  The file does exist
  2.  The file is not being used by another program
  3.  The path is correct
  4.  The python script is being successfully used by users with administrative privileges

Please find bellow the method I am using to open the excel file:


import win32com.client as w3c



filename = 'C:\\\\App\\\\Backend\\\\public\\\\MSB_2021\\\\11\\\\SYB_10_7_V1.xlsx'

ExcelApp = w3c.DispatchEx("Excel.Application")
ExcelApp.Visible = False
ExcelApp.DisplayAlerts = False
wb = ExcelApp.Workbooks.Open("{0}".format(fileName))

Appreciate your help.

Best,
Tamara

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/python-win32/attachments/20211212/332c20da/attachment.html>


More information about the python-win32 mailing list