[python-win32] Problem with simple example

Murr Von Kater newmurr at gmail.com
Tue Jul 29 15:34:54 CEST 2008


Hi all!

I'm beginer in python-win32 and i try a simple example which is described in
"Python for Win32 Extensions Help":

import win32com.client
o = win32com.client.Dispatch("Excel.Application")
o.Visible = 1
o.Workbooks.Add() # for office 97 – 95 a bit different!
o.Cells(1,1).Value = "Hello"

But this example falls with traceback:

  File "D:\Python25\pyprojects\pyexample\pyexample.py", line 6, in <module>
    o.Workbooks.Add() # for office 97 – 95 a bit different!
  File "D:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 467,
in __getattr__
    if self._olerepr_.mapFuncs.has_key(attr): return
self._make_method_(attr)
  File "D:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 295,
in _make_method_
    methodCodeList =
self._olerepr_.MakeFuncMethod(self._olerepr_.mapFuncs[name], methodName,0)
  File "D:\Python25\Lib\site-packages\win32com\client\build.py", line 297,
in MakeFuncMethod
    return self.MakeDispatchFuncMethod(entry, name, bMakeClass)
  File "D:\Python25\Lib\site-packages\win32com\client\build.py", line 318,
in MakeDispatchFuncMethod
    s = linePrefix + 'def ' + name + '(self' + BuildCallList(fdesc, names,
defNamedOptArg, defNamedNotOptArg, defUnnamedArg, defOutArg) + '):'
  File "D:\Python25\Lib\site-packages\win32com\client\build.py", line 604,
in BuildCallList
    argName = MakePublicAttributeName(argName)
  File "D:\Python25\Lib\site-packages\win32com\client\build.py", line 542,
in MakePublicAttributeName
    return filter( lambda char: char in valid_identifier_chars, className)
  File "D:\Python25\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 0x80 in position 52:
ordinal not in range(128)

Is it bug or may be i should set some settings to make it works? I use WinXP
and MS Office 2003. Python-win32 has been intalled on my PC with
pywin32-211.win32-py2.5.exe installer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20080729/8a95263b/attachment.htm>


More information about the python-win32 mailing list