Thank you very much. You are right.The problem is my office is not correct.When I reinstalled my Microsoft office, The problem solved.Thank you . Best wishes to you.
-----邮件原件----- 发件人: Mark Hammond [mailto:skippy.hamm...@gmail.com] 发送时间: 2013年12月16日 10:57 收件人: WangMengNan(桌面事业部); python-win32@python.org 主题: Re: [python-win32] pywintypes.com_error: (-2147221164 On 15/12/2013 10:37 PM, WangMengNan(桌面事业部) wrote: > Hi,All: > > Sorry to bother you. > > I have a python2.7 program,my pc's environment is win7,32bit.I want to > use win32com,and I have installed > > win32com for python2.7. When I worte the code"xls = > client.Dispatch("Excel.Application")",an error happened: > > Traceback (most recent call last): > > _File "D:\JackieCodeProject\python\newvenus\excel_yanxiaoqing.py", > line 168, in <module>_ > > write_to_mysql(r'C:\V4.2.xlsx',"王梦楠",1294) > > _File "D:\JackieCodeProject\python\newvenus\excel_yanxiaoqing.py", > line 76, in write_to_mysql_ > > case_list = getlist_from_excel(file_name) > > _File "D:\JackieCodeProject\python\newvenus\excel_yanxiaoqing.py", > line 27, in getlist_from_excel_ > > xls = client.Dispatch("Excel.Application") > > _File "C:\Python27\lib\site-packages\win32com\client\__init__.py", > line 95, in Dispatch_ > > dispatch, userName = > dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) > > _File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line > 108, in _GetGoodDispatchAndUserName_ > > return (_GetGoodDispatch(IDispatch, clsctx), userName) > > _File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line > 85, in _GetGoodDispatch_ > > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, > pythoncom.IID_IDispatch) > > pywintypes.com_error: (-2147221164, > '\xc3\xbb\xd3\xd0\xd7\xa2\xb2\xe1\xc0\xe0', None, None) This is "Class not registered". I suspected you have a 64bit version of Python, but only a 32bit version of Excel installed (or vice-versa), but you mention you are running a 32bit environment - are you completely sure about that? Otherwise, it simply seems Excel wasn't correctly installed. HTH, Mark > > I need you help. > > > > _______________________________________________ > python-win32 mailing list > python-win32@python.org > https://mail.python.org/mailman/listinfo/python-win32 > _______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32