comtypes
comtypes copied to clipboard
How do I access enumerations?
How do I access enumerations and their values such as powerpoint.ppsaveasfiletype through comtypes?
I answered your Stack Overflow question, but let’s record it here too:
Use the comtypes.client.Constants() class to access all associated enum names, including those defined on the ppSaveAsFileType enum:
from comtypes.client import Constants, CreateObject
powerpoint = CreateObject("Powerpoint.Application")
pp_constants = Constants(powerpoint)
pres = powerpoint.Presentations.Open(input_path)
pres.SaveAs(output_path, pp_constants.ppSaveAsPDF)
Maintainers: why is the Constants() class not documented?
TIL there is a Constants class. (That's my excuse.)
😆 Added in December 2008 https://github.com/enthought/comtypes/blob/1d3d38b2a616674309e7eabe6b5c581042caf32a/CHANGES.txt#L320-L330
@OskarPersson @mjpieters @cfarrow
If the issue remains, please re-open.