2

今天突然出现以下错误。

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)

怎么了?

4

1 回答 1

0

对于 anwser 来说可能有点晚了,但是您缺少 Excel 和 Application 之间的点。“Excel.Application”)。

于 2013-02-09T15:07:41.340 回答