I am trying to use the stock standard win32com approach to drive Excel 2007 from Python. However, when I try to create a new workbook, things go pear-shaped:
Python 2.6.4 (r264:75706, Nov 3 2009, 13:23:17) [MSC v.1500 32 bit (Intel)] on win32
...
>>> import win32com.client
>>> excel = win32com.client.Dispatch("Excel.Application")
>>> wb = excel.Workbooks.Add()
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
wb = excel.Workbooks.Add()
File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line 467, in __getattr__
if self._olerepr_.mapFuncs.has_key(attr): return self._make_method_(attr)
File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line 295, in _make_method_
methodCodeList = self._olerepr_.MakeFuncMethod(self._olerepr_.mapFuncs[name], methodName,0)
File "C:\Python26\lib\site-packages\win32com\client\build.py", line 297, in MakeFuncMethod
return self.MakeDispatchFuncMethod(entry, name, bMakeClass)
File "C:\Python26\lib\site-packages\win32com\client\build.py", line 318, in MakeDispatchFuncMethod
s = linePrefix + 'def ' + name + '(self' + BuildCallList(fdesc, names, defNamedOptArg, defNamedNotOptArg, defUnnamedArg, defOutArg) + '):'
File "C:\Python26\lib\site-packages\win32com\client\build.py", line 604, in BuildCallList
argName = MakePublicAttributeName(argName)
File "C:\Python26\lib\site-packages\win32com\client\build.py", line 542, in MakePublicAttributeName
return filter( lambda char: char in valid_identifier_chars, className)
File "C:\Python26\lib\site-packages\win32com\client\build.py", line 542, in <lambda>
return filter( lambda char: char in valid_identifier_chars, className)
UnicodeDecodeError: 'ascii' codec can't decode byte 0x83 in position 52: ordinal not in range(128)
>>>
What is going wrong here? Have I done something silly, or is Python/win32com/Excel somehow broken?