user3381431
user3381431

Reputation: 93

find out ProgID for com object using pywin32

I can declare a com object in python via pywin32 using the following code

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

But how do I find out the ProgID (ie "Outlook.Application") for other com objects if I don't know them beforehand?

Upvotes: 0

Views: 1774

Answers (2)

Matteo Boscolo
Matteo Boscolo

Reputation: 51

you can also try the ProgIDFromCLSID from pythoncom

https://timgolden.me.uk/pywin32-docs/pythoncom__ProgIDFromCLSID_meth.html

this raise an exception if the object is not found

>>> pythoncom.ProgIDFromCLSID("Inventor.NoApplication")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)
>>> pythoncom.ProgIDFromCLSID("Inventor.Application")
u'Inventor.Application.1'

Upvotes: 0

Joseph Willcoxson
Joseph Willcoxson

Reputation: 6050

It was suggested I post my comment as an answer:

Unclear what your question is... You can discover by looking in the registry, HKEY_CLASSES_ROOT and find a bunch of ProgIDs. The OLEVIEW.EXE tool that ships with Visual Studio shows objects and type libraries that are available. But, usually I don't create objects at random but have an idea of the object I want to create and I try to create that one. What difference does it make if there are other objects?

https://learn.microsoft.com/en-us/windows/win32/com/-progid--key

Upvotes: 0

Related Questions