Win32com.client com_error

时间:2012-06-24 14:56:13

标签: python error-handling

今天我突然发现以下错误。

import win32com.client
xl=win32com.client.Dispatch("Excel Application")

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    xl=win32com.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)
com_error: (-2147221005, 'Invalid class string', None, None)

有什么问题?

1 个答案:

答案 0 :(得分:0)

答案可能有点迟,但您错过了Excel和Application之间的点。 “Excel.Application”)。