To find out what Com applications you can use... See http://timgolden.me.uk/pywin32-docs/html/com/win32com/HTML/QuickStartClientCom.html

Basically you can't know for sure. Sorry. Each computer will have a different list based on the software installed, the webpage I linked suggests using pyWins ComBrowser, however I haven't ever found it that useful.

My normal approach is 'I want to interface with application X in Python... lets google "python com X" and see what comes up' or 'I want to interface with application X in Python.. lets look through the documentation of AppX for references to COM'

Afterall you'll want to have some form of documentation to that programmes COM interface in order to be able to do anything meaningful with the program (other than opening it).

Answer from CastleH on Stack Overflow
🌐
WMI
timgolden.me.uk › pywin32-docs › html › com › win32com › HTML › QuickStartClientCom.html
Quick Start to Client side COM and Python - Tim Golden
Hopefully, the answer is you shouldn't need to. All generated file support is generally available directly via win32com.client.Dispatch and win32com.client.constants. But should you ever really need the Python module object, the win32com.client.gencache module has functions specifically for this.
🌐
IARP
iarp.github.io › python › python3-win32com-constants.html
Python 3 accessing win32com.client.constants | IARP
March 1, 2016 - Python doesn’t know what olFolderInbox is by default, it’s just another variable that is undefined yet. win32com gives you access to these constants by going to win32com.client.constants.WhatEverYouNeed.
Top answer
1 of 1
2

The short answer is to change:

outlookApp = win32com.client.Dispatch("Outlook.Application")

to

outlookApp = win32com.client.gencache.EnsureDispatch("Outlook.Application")

The longer answer is that win32com can work with COM interfaces in one of two ways: late- and early-binding.

With late-binding, your code knows nothing about the Dispatch interface ie. doesn't know which methods, properties or constants are available. When you call a method on the Dispatch interface, win32com doesn't know if that method exists or any parameters: it just sends what it is given and hopes for the best!

With early-binding, your code relies on previously-captured information about the Dispatch interface, taken from its Type Library. This information is used to create local Python wrappers for the interface which know all the methods and their parameters. At the same time it populates the Constants dictionary with any constants/enums contained in the Type Library.

win32com has a catch-all win32com.client.Dispatch() function which will try to use early-binding if the local wrapper files are present, otherwise will fall back to using late-binding. My problem with the package is that the caller doesn't always know what they are getting, as in the OP's case.

The alternative win32com.client.gencache.EnsureDispatch() function enforces early-binding and ensures any constants are available. If the local wrapper files are not available, they will be created (you might find them under %LOCALAPPDATA%\Temp\gen_py\xx\CLSID where xx is the Python version number, and CLSID is the GUID for the Type Library). Once these wrappers are created once then the generic win32com.client.Dispatch() will use these files.

🌐
Python
mail.python.org › pipermail › python-win32 › 2006-February › 004296.html
[python-win32] Using win32com Constants
January 19, 2013 - So yesterday's expression: win32com.client.constants.__dict__["__dicts__"][0].keys() is really the same as win32com.client.constants.__dicts__[0].keys() And I think this is because win32com.client.constants.__dicts__[0] is a attribute:value hash for the win32com.client.Constant object win32com.client.constants, which includes -all- the attributes of the object as well as the constant/value pairs I was after.
🌐
Bytes
bytes.com › home › forum › topic › python
win32com.client.constants - AttributeError - Post.Byes
April 20, 2006 - Re: win32com.client .constants - AttributeError The constants are only available if you've run makepy on the Word object library.
🌐
The Coding Forums
thecodingforums.com › archive › archive › python
win32con.client.constants error | Python | Coding Forums
April 2, 2007 - Traceback (most recent call last): File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\Documents and Settings\bnewberg\Desktop\mail_script\mail_move_init_test.py", line 22, in ? msgFolderTypeConsts = {'Rcvd': constants.olFolderInbox, 'Sent': constants.olFolderSentMail} File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 168, in __getattr__ raise AttributeError, a AttributeError: olFolderInbox Code snippet: from win32com.client import gencache, constan [SNIP] class MSOutlook(object
Find elsewhere
🌐
Py2exe
py2exe.org › index.cgi › IncludingTypelibs
IncludingTypelibs - py2exe.org
November 26, 2017 - Typically when dealing with 3rd party COM libraries (eg. Office), you make use of the constants defined in that library. Once makepy creates the typelib for you, using these constants is normally easy in python. You only need to import win32com.client.constants to access them · However, since ...
🌐
GitHub
github.com › khchen › winim › issues › 15
how to read COM object's constants? · Issue #15 · khchen/winim
August 5, 2018 - import winim.com comScript: #~ if true: let word = CreateObject("Word.Application") #~ echo (com.client.constants.wdLineSpaceExactly) echo "undeclared identifier: 'client'" #~ echo (client.constants.wdLineSpaceExactly) echo "undeclared identifier: 'client'" #~ echo (constants.wdLineSpaceExactly) echo "undeclared identifier: 'constants'" #~ echo (wdLineSpaceExactly) echo "undeclared identifier: 'wdLineSpaceExactly'" #~ echo (word.wdLineSpaceExactly) echo "unhandled exception: unsupported method: wdLineSpaceExactly [COMError]" word.Quit() COM_FullRelease()
Author   khchen
Top answer
1 of 2
1

When you are running EnsureDispatch, win32com will automatically generate Python code corresponding to the type library of interest.

Depending a bit on your environment, the Python modules will be located somewhere around C:\Users\username\AppData\Local\Temp\gen_py\3.6, with the modules being grouped by the CLSID of the type library you have generated code for.

For PowerPoint 2016, you would find a folder named 91493440-5A91-11CF-8700-00AA0060263B whose __init__.py contains all the generated constants, including e.g. ppFixedFormatTypePDF.

Now, notably, the MsoTriState enum containing msoFalse is not part of the PowerPoint type library, which is why you are seeing your AttributeErrors.

From a quick look at the documentation, we find that the enum is part of the core Office libraries, contained in mso.dll. Depending once again on your setup, which version of Office you're using, and which architecture it targets, you should be able to dig up its ID by searching HKEY_CLASSES_ROOT in your registry editor:

Here, we note that the type library has a CLSID of {2DF8D04C-5BFA-101B-BDE5-00AA0044DE52} and that the version number is 2.8. Knowing this, perhaps the easiest way to generate the code for the library, and thus the missing constant, is through win32com.client.gencache.EnsureModule('{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}', 0, 2, 8):

In [16]: win32com.client.constants.msoFalse
AttributeError: msoFalse

In [17]: win32com.client.gencache.EnsureModule('{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}', 0, 2, 8)
Out[17]: <module 'win32com.gen_py.2DF8D04C-5BFA-101B-BDE5-00AA0044DE52x0x2x8' from 'C:\\Users\\username\\AppData\\Local\
\Temp\\gen_py\\3.6\\2DF8D04C-5BFA-101B-BDE5-00AA0044DE52x0x2x8.py'>

In [18]: win32com.client.constants.msoFalse
Out[18]: 0

Now, knowing that msoFalse translates to a 0, you could, of course, also just skip the entire process and replace all occurrences of the constant with a 0.

2 of 2
0
 __import__('win32com.gen_py', globals(), locals(), ['2DF8D04C-5BFA-101B-BDE5-00AA0044DE52x0x2x8'], 0)

this file will not be automatically loaded.

🌐
O'Reilly
oreilly.com › library › view › python-programming-on › 1565926218 › ch12s03s05.html
12.3.5. Using COM Constants - Python Programming On Win32 [Book]
Using COM ConstantsMany COM type libraries also include enumerations, which are named constants and used with the type library. For example, the type library used with Microsoft... - Selection from Python Programming On Win32 [Book]
🌐
GitHub
github.com › mhammond › pywin32 › blob › main › com › win32com › HTML › QuickStartClientCom.html
pywin32/com/win32com/HTML/QuickStartClientCom.html at main · mhammond/pywin32
March 25, 2013 - <P>Makepy automatically installs all generated constants from a type library in an object called <I>win32com.clients.constants</I>. You do not need to do anything special to make these constants work, other than create the object itself (ie, in the example above, the constants relating to <I>Word</I> would automatically be available after the <CODE>w=win32com.client.Dispatch("Word.Application</CODE>") statement<CODE>.</P>
Author   mhammond
🌐
GitHub
github.com › SublimeText › Pywin32 › blob › master › lib › x32 › win32com › HTML › QuickStartClientCom.html
Pywin32/lib/x32/win32com/HTML/QuickStartClientCom.html at master · SublimeText/Pywin32
<P>Makepy automatically installs all generated constants from a type library in an object called <I>win32com.clients.constants</I>. You do not need to do anything special to make these constants work, other than create the object itself (ie, in the example above, the constants relating to <I>Word</I> would automatically be available after the <CODE>w=win32com.client.Dispatch("Word.Application</CODE>") statement<CODE>.</P>
Author   SublimeText
🌐
Helperbyte
helperbyte.com › questions › 284301 › how-to-use-win32comclient-from-thread
How to use win32com.client from thread? - Python - Helperbyte
September 18, 2019 - There are two codes, one is working:#!/usr/bin/python2 # -*- coding: cp1251 -*- from win32com.client import constants import win32com.client sapi = win32com.client.Dispatch("SAPI.SpVoice") phrase = "Hello,
🌐
Note
note.com › トップ › コンピュータ・it › プログラミング › pythonの win32com について
Pythonの win32com について|whale999
March 9, 2025 - Using Excel constants: Importing win32com.client.constants allows you to use Excel and Office constants by name.
🌐
The Coding Forums
thecodingforums.com › archive › archive › python
win32com.client.constants - AttributeError | Python | Coding Forums
April 21, 2006 - On my machine, this runs fine, but when I try to run it on someone elses machine it blows up with an attribute error: <code> import win32com.client, pythoncom pythoncom.CoInitializeEx(pythoncom.COINIT_APARTMENTTHREADED) myWord = win32com.client.dynamic.Dispatch ("Word.Application") myWord.Visible = True myDoc = myWord.Documents.Open(FileName= "C:\Test.doc") myDoc .SaveAs(FileName = "c:\Test.htm", FileFormat = win32com.client.constants.wdFormatHTML) myDoc.Saved=1 myWord.Quit () del myWord pythoncom.CoUninitialize() </code> It's pretty simple code so I don't understand why it doesn't work.
🌐
GitHub
github.com › mhammond › pywin32 › issues › 1424
ImportError: cannot import name 'MSO' from 'win32com.client' (C:\Python37\lib\site-packages\win32com\client\__init__.py) · Issue #1424 · mhammond/pywin32
October 5, 2019 - # -*- coding: utf-8 -*- import os import win32com.client from win32com.client import constants as c, Dispatch, MSO import string from pandas import Series import pythoncom ...
Author   mhammond