简体   繁体   中英

What is stopping win32.Dispatch() from opening Microsoft Office programs?

I am attempting to open Outlook using the following Python code:

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. I can't open any other Microsoft Office applications this way either. However, others (Adobe Illustrator, for example) will open just fine using this method.

Outlook and friends are definitely installed, and I can open Outlook using:

os.startfile('outlook')

Am I missing something that makes Office apps special with regard to the COM interface?

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. I'd recommend repairing MS Office or Outlook to get all the keys restored correctly.

Also you may try to automate Outlook from any other Office application. If it works then windows registry keys are fine and the problem is related to the win32com library.

I wonder if perhaps Outlook is starting but is simply not visible?

Have you tried some of the techniques shown in this SO answer? Clearly documented reading of emails functionality with python win32com outlook

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM