[pywin32-bugs] [ pywin32-Bugs-1619086 ] Excel sort fails w/ early binding in Python 2.2.3
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2006-12-19 22:06:59
|
Bugs item #1619086, was opened at 2006-12-19 11:07 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=1619086&group_id=78018 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: com Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Craig (craigch) Assigned to: Nobody/Anonymous (nobody) Summary: Excel sort fails w/ early binding in Python 2.2.3 Initial Comment: I am using Python 2.2.3 with Pywin32-210.win32-py2.2 The following Python sequence works fine when using the 'late binding' method. import win32com.client.dynamic import types xlApp = win32com.client.Dispatch("Excel.Application") xlBook = xlApp.Workbooks.Open( 'C:\\TestExcel.xls' ) sheet = xlBook.Worksheets( 1 ) sheet.Activate() rangeToSort = xlApp.Range('a2:e5') rangeToSort.Sort( Key1=sheet.Columns( 3 ), Order1=1 , Header=1 ) Since I required the use of the GetOffset function when using COM with Excel, I compiled the Excel 11.0 Object Library using the COM MakePy Utility in PythonWin. When I run the above sequence now, I get the following error. If I then delete the generated Excel 11.0 .py file in the win32com\gen_py directory. The sequence will then run without a problem. Traceback (most recent call last): File "C:\Python22\Tools\idle\Debugger.py", line 37, in run return apply(bdb.Bdb.run, (self,) + args) File "C:\Python22\lib\bdb.py", line 349, in run exec cmd in globals, locals File "<pyshell#10>", line 1, in ? rangeToSort.Sort( Key1=sheet.Columns( 3 ), Order1=1 , Header=1 ) File "C:\Python22\lib\site-packages\win32com\gen_py\00020813-0000-0000-C000-000000000046x0x1x5.py", line 22609, in Sort, SortMethod, DataOption1, DataOption2, DataOption3) File "C:\Python22\Lib\site-packages\win32com\client\__init__.py", line 446, in _ApplyTypes_ return self._get_good_object_( com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft Office Excel', "The sort reference is not valid. Make sure that it's within the data you want to sort, and the first Sort By box isn't the same or blank.", 'C:\\Program Files\\Microsoft Office\\OFFICE11\\1033\\xlmain11.chm', 0, -2146827284), None) Varying the setting of the 'bForDemand' parameter did not seems to affect the problem behavior. I am using Python 2.2.3 in conjunction with a 3rd party app and do not have the option of moving to a upgraded/fixed version of Python at this time. One workaround that I have is to remove the generated Excel 11.0 .py file and no longer use the GetOffset call in my Python code, but wondered if there is a known fix to the above problem. Thanks, Craig ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=1619086&group_id=78018 |