[英]win32com.client.Dispatch(“Outlook.Application”) error pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)
I am on windows 7 and I have windows live installed. 我在Windows 7上安装了Windows Live。 Now when I am trying to run following code
现在,当我尝试运行以下代码时
import win32com.client
win32com.client.Dispatch("Outlook.Application")
I am getting following error 我收到了以下错误
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 95, in
Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,c
lsctx)
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.II
D_IDispatch)
pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)
I have another machine with windows xp and Outlook installed. 我有另一台安装了Windows XP和Outlook的机器。 I ran the same code and I got the same error.
我运行相同的代码,我得到了同样的错误。
One more question. 还有一个问题。 How can I get the com of windows live on windows 7?
如何在Windows 7上获得Windows的com?
Any suggestions and comments will be appreciated. 任何建议和意见将不胜感激。
This is an indication that Outlook is not installed. 这表示未安装Outlook。 "
windows live
" or " outlook.com
" would not help you. “
windows live
”或“ outlook.com
”对你没有帮助。
I was having a similar error. 我遇到了类似的错误。 Have you tried running makepy.py from win32com's folder to create entries for the different COMobject's you are using?
您是否尝试从win32com的文件夹中运行makepy.py来为您正在使用的不同COM对象创建条目? Basically, win32com just treats all of applications you interact with as default COMobjects until you let it learn about the programs installed on your computer.
基本上,win32com只会将您与之交互的所有应用程序视为默认的COM对象,直到您了解计算机上安装的程序为止。 You'll have to run makepy.py for each program you want to control with it.
您必须为要使用它控制的每个程序运行makepy.py.
After I ran it, I gained access to much more control for Outlook. 运行它之后,我获得了对Outlook的更多控制权。 It has opened other errors that I am working on correcting.
它已经打开了我正在纠正的其他错误。
Also, if you take your comobject ( comboject = win32com.client.Dispatch("Outlook.Application") ) and look at comboject._prop_map_get_.keys() you'll see all the things you can use for that program. 此外,如果您使用comobject( comboject = win32com.client.Dispatch(“Outlook.Application”) )并查看comboject._prop_map_get_.keys(),您将看到可以用于该程序的所有内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.