Hi,
mabe it is a PowerPoint 2007 bug, but I couldn`t find a solution to use the function ExportAsFixedFormat of PowerPoint 2007. I get a value error (not a COM object) with following code. I think the ppFixedFormatIntentScreen constant must be of another type. Because without that constant it works fine. But I cannot set other constants?!
import glob, win32com.client, pythoncom
pptFiles = glob.glob('c:\\testdokumente\\ppt\\*.ppt')
for pptFile in pptFiles:
PPT=win32com.client.gencache.EnsureDispatch('powerpoint.application')
print 'Converting %s' % pptFile
#PPT.Activate()
presentation = PPT.Presentations.Open(pptFile, False, False, False)
presentation.ExportAsFixedFormat(pptFile+'.pdf', win32com.client.constants.ppFixedFormatTypePDF, win32com.client.constants.ppFixedFormatIntentScreen)
Output:
Converting c:\testdokumente\ppt\file_no_0.ppt
Traceback (most recent call last):
File "C:\Python25\Lib\SITE-P~1\PYTHON~1\pywin\framework\scriptutils.py", line 310, in RunScript
exec codeObject in __main__.__dict__
File "C:\Dokumente und Einstellungen\mgo\Desktop\ppt_getobject.py", line 9, in <module>
presentation.ExportAsFixedFormat(pptFile+'.pdf', win32com.client.constants.ppFixedFormatTypePDF, win32com.client.constants.ppFixedFormatIntentScreen)
File "C:\DOKUME~1\mgo\LOKALE~1\Temp\gen_py\2.5\91493440-5A91-11CF-8700-00AA0060263Bx0x2x9.py", line 7866, in ExportAsFixedFormat
, KeepIRMSettings, DocStructureTags, BitmapMissingFonts, UseISO19005_1, ExternalExporter
File "C:\Python25\lib\site-packages\win32com\client\__init__.py", line 448, in _ApplyTypes_
dispid, 0, wFlags, retType, argTypes, *args),
ValueError: argument is not a COM object
>>>
Example python script
Logged In: YES
user_id=14198
Originator: NO
"ValueError: argument is not a COM object" generally means that one of the params is expecting an object, not a simple type such as an integer. You might like to post your question to the python-win32@python.org mailing list where more people will see it
Logged In: YES
user_id=977439
Originator: NO
This is a bug in Powerpoint. It defines "[in, optional, defaultvalue(0)] PrintRange* PrintRange" which leads to the generation of "PrintRange=0" in the python wrapper. Therefore you'll get the error when calling the method. So no problem of makepy. Workaround call the method with PrintRange=None since None is a vali COM object. E.g. presentation.ExportAsFixedFormat(pptFile+'.pdf',
win32com.client.constants.ppFixedFormatTypePDF,
win32com.client.constants.ppFixedFormatIntentScreen, PrintRange=None)
should work.
Logged In: YES
user_id=1525528
Originator: YES
It works !!!