Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.0k views
in Technique[技术] by (71.8m points)

xlwings - pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147352565), None)

I was created example from http://docs.xlwings.org/en/stable/vba.html /Python 3.5.1 |Anaconda 2.5.0 (32-bit)| (default, Jan 29 2016, 15:46:01)/ and got error

--
---------------------------
Error
---------------------------
Traceback (most recent call last):

  File "<string>", line 1, in <module>

  File "C:Python3mymodule.py", line 7, in rand_numbers

    n = int(Range('Sheet1', 'B1').value)  # Write desired dimensions into Cell B1

  File "C:Python3libsite-packagesxlwingsmain.py", line 701, in __init__

    self.xl_sheet = xlplatform.get_worksheet(self.xl_workbook, sheet_name_or_index)

  File "C:Python3libsite-packagesxlwings\_xlwindows.py", line 240, in get_worksheet

    return xl_workbook.Sheets(sheet)

  File "C:Python3libsite-packageswin32comclientdynamic.py", line 192, in __call__

    return self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None)

pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147352565), None)



Press Ctrl+C to copy this message to the clipboard.
---------------------------
OK   
---------------------------
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Hey so the error means:

>>> import win32api
>>> win32api.FormatMessage(-2147352565)
'Invalid index.
'

So my guess is that you're trying to write to an inexistent sheet (and yes, we shall be working on easier-to-understand error messages...)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...