<div dir="ltr">Dear all, <br><br>I have a problem with talking to Excel. Somehow the command Workbooks.Add() gives me problems?<br>If I open a workbook in Excel, then I get the trace back below. I can not say that I quite understand why this does not work. Any insights would be highly appreciated.<br>
<br>If I "manually" open the workbook, I can fill the data in the sheet<br><br>Johan<br><br><br>>>> from win32com.client import Dispatch<br>>>> xlApp = Dispatch("Excel.Application")<br>
>>> xlApp.Visible = 1<br>>>> xlApp.Workbooks.Add()<br><br>Traceback (most recent call last):<br> File "<pyshell#67>", line 1, in <module><br> xlApp.Workbooks.Add()<br> File "c:\pythonxy\python\lib\site-packages\pywin32-2.11-py2.5-win32.egg\win32com\client\dynamic.py", line 467, in __getattr__<br>
if self._olerepr_.mapFuncs.has_key(attr): return self._make_method_(attr)<br> File "c:\pythonxy\python\lib\site-packages\pywin32-2.11-py2.5-win32.egg\win32com\client\dynamic.py", line 295, in _make_method_<br>
methodCodeList = self._olerepr_.MakeFuncMethod(self._olerepr_.mapFuncs[name], methodName,0)<br> File "c:\pythonxy\python\lib\site-packages\pywin32-2.11-py2.5-win32.egg\win32com\client\build.py", line 297, in MakeFuncMethod<br>
return self.MakeDispatchFuncMethod(entry, name, bMakeClass)<br> File "c:\pythonxy\python\lib\site-packages\pywin32-2.11-py2.5-win32.egg\win32com\client\build.py", line 318, in MakeDispatchFuncMethod<br> s = linePrefix + 'def ' + name + '(self' + BuildCallList(fdesc, names, defNamedOptArg, defNamedNotOptArg, defUnnamedArg, defOutArg) + '):'<br>
File "c:\pythonxy\python\lib\site-packages\pywin32-2.11-py2.5-win32.egg\win32com\client\build.py", line 604, in BuildCallList<br> argName = MakePublicAttributeName(argName)<br> File "c:\pythonxy\python\lib\site-packages\pywin32-2.11-py2.5-win32.egg\win32com\client\build.py", line 542, in MakePublicAttributeName<br>
return filter( lambda char: char in valid_identifier_chars, className)<br> File "c:\pythonxy\python\lib\site-packages\pywin32-2.11-py2.5-win32.egg\win32com\client\build.py", line 542, in <lambda><br> return filter( lambda char: char in valid_identifier_chars, className)<br>
UnicodeDecodeError: 'ascii' codec can't decode byte 0x83 in position 52: ordinal not in range(128)<br>>>> <br></div>