[英]What is stopping win32.Dispatch() from opening Microsoft Office programs?
I am attempting to open Outlook using the following Python code:我正在尝试使用以下 Python 代码打开 Outlook:
import os
import win32com.client as win32
outlook = win32.Dispatch('Outlook.Application')
This does not work, but it doesn't throw an error either, which it does when I replace Outlook with a random word.这不起作用,但它也不会引发错误,当我用随机词替换 Outlook 时会发生错误。 I can't open any other Microsoft Office applications this way either.
我也无法以这种方式打开任何其他 Microsoft Office 应用程序。 However, others (Adobe Illustrator, for example) will open just fine using this method.
但是,其他人(例如 Adobe Illustrator)可以使用此方法正常打开。
Outlook and friends are definitely installed, and I can open Outlook using: Outlook 和朋友肯定安装了,我可以使用以下命令打开 Outlook:
os.startfile('outlook')
Am I missing something that makes Office apps special with regard to the COM interface?我是否遗漏了一些使 Office 应用程序在 COM 界面方面特别的东西?
It would be great to specify exactly what you get from the following call:最好准确指定您从以下调用中获得的内容:
outlook = win32.Dispatch('Outlook.Application')
If Outlook can't be instantiated this way then its windows registry keys were corrupted.如果不能以这种方式实例化 Outlook,则其 Windows 注册表项已损坏。 I'd recommend repairing MS Office or Outlook to get all the keys restored correctly.
我建议修复 MS Office 或 Outlook 以正确恢复所有密钥。
Also you may try to automate Outlook from any other Office application.您也可以尝试从任何其他 Office 应用程序自动化 Outlook。 If it works then windows registry keys are fine and the problem is related to the
win32com
library.如果它有效,则 Windows 注册表项很好,问题与
win32com
库有关。
I wonder if perhaps Outlook is starting but is simply not visible?我想知道 Outlook 是否正在启动但根本不可见?
Have you tried some of the techniques shown in this SO answer?您是否尝试过此 SO 答案中显示的一些技术? Clearly documented reading of emails functionality with python win32com outlook
使用 python win32com outlook 清楚记录阅读电子邮件功能
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.