pywin can not access excel file

Tamara Abugharbieh <[email protected]> Sun, 12 Dec 2021 08:32:01 +0000
Newsgroups gmane.comp.python.windows
Message-ID <AS8PR02MB7446F82B82E51E04396ED284CC739@AS8PR02MB7446.eurprd02.prod.outlook.com>
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

_______________________________________________
python-win32 mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-win32