今天突然我得到以下错误。

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)

怎么了?

最佳答案

答案可能为时已晚,但是您缺少Excel和Application之间的点。 “Excel.Application”)。

关于python - Win32com.client com_error,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11178464/

10-08 22:01