简体   繁体   English

是什么阻止 win32.Dispatch() 打开 Microsoft Office 程序?

[英]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.

相关问题 Python 中的 win32.Dispatch 与 win32.gencache。 优缺点都有什么? - win32.Dispatch vs win32.gencache in Python. What are the pros and cons? 监控通过 Python win32.Dispatch('Outlook.Application') 发送的电子邮件? - Monitor E-mail sent via Python win32.Dispatch('Outlook.Application')? Word = win32.Dispatch("Word.Application") 尽管有 Word.Visible = False 命令,但每隔一次显示打开的文件 - Word = win32.Dispatch("Word.Application") Displays the opened file every other time despite Word.Visible = False command win32com.client.Dispatch 打开不需要的独木舟版本 - win32com.client.Dispatch opening the undesired canoe version 使用 win32com.client.dispatch 函数在 python 中打开 Excel 和 Word 时的不同行为 - Different behaviour when opening Excel and Word in python using win32com.client.dispatch function 是否有可能在没有机器上的microsoft office的情况下运行win32com脚本 - Is it possible to run win32com script without having microsoft office on the machine win32com.client.Dispatch(“WScript.Shell”)究竟是什么? - What exactly does win32com.client.Dispatch(“WScript.Shell”)? win32com.client.dispatch("Redemption.RDOSession") 使用特定目录中的 dll - win32com.client.dispatch("Redemption.RDOSession") to use dll from a specific directory 如何从win32com.client.dispatch获取属性(“Shell.Application”) - how to get attributes from win32com.client.dispatch(“Shell.Application”) “调用的对象已与其客户端断开连接”win32com.client.Dispatch('CANalyzer.Application') - “The object invoked has disconnected from its clients” win32com.client.Dispatch('CANalyzer.Application')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM