[python-win32] Help with com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft Excel', u"Microsoft Excel cannot access the file

Doug Sharkey douglas.sharkey at gmail.com
Fri Dec 2 16:56:40 EST 2016


Hi all,

This bit of code:

           objExcel = win32com.client.Dispatch("Excel.Application")
            objExcel.visible = False
            objExcel.DisplayAlerts = False
            objWb=objExcel.Workbooks.Open(filename)

is producing this error:

 File "<COMObject <unknown>>", line 8, in Open
com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft Excel',
u"Microsoft Excel cannot access the file
'\\\\Win-rfe2cu0ucdn\\EFT_Share\\EFT_ToBeProcessed\\ABCD\\MyFile.P'. There
are several possible reasons:\n\n\u2022 The file name or path does not
exist.\n\u2022 The file is being used by another program.\n\u2022 The
workbook you are trying to save has the same name as a currently open
workbook.", u'xlmain11.chm', 0, -2146827284), None)

Note:

1. filename is fully qualified (filename=os.path.abspath(...))
2. The file does exist
3. The file is not being used by another program
4. There is no other open workbook

My environment is:

   - Windows Server 2012 R2, 64bit OS
   - Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC
   v.1500 64 bit (AMD64)] on win32
   - pywin32-220.win-amd64-py2.7
   - MIcrosoft Excel 2013, 64bit

If I run it from my laptop (Windows 8.1 Enterprise, 64bit OS) it works fine.

Any help is appreciated. I've been wracking my brain on this for the past 5
days.

Thanks,

Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20161202/1ee18ca4/attachment.html>


More information about the python-win32 mailing list