This is a Bug in the PowerPoint API.
Workaround: Pass the keyword argument PrintRange=None.
For details see: https://sourceforge.net/p/pywin32/bugs/339/
Question
I'm trying to convert a .pptx file to .pdf using python and win32com. The code I'm using looks like this:
ppoint = win32.gencache.EnsureDispatch("Powerpoint.Application")
ppoint.Visible = True
pres = ppoint.Presentations.Open(PPT_FILE_NAME)
pres.ExportAsFixedFormat(PDF_FILE_NAME, 2, 0, 0, 1, 1, False, 1, False, False, False,False)
The problem is that ExportAsFixedFormat throws an error:
Traceback (most recent call last): File "converter.py", line 30, in pres.ExportAsFixedFormat(PDF_FILE_NAME2, 2, 0, 0, 1, 1, False, 1, False, Fal se, False,False) File "D:\applics\Python\lib\site-packages\win32com\gen_py\91493440-5A91-11CF-8 700-00AA0060263Bx0x2x11_Presentation.py", line 112, in ExportAsFixedFormat , KeepIRMSettings, DocStructureTags, BitmapMissingFonts, UseISO19005_1, Exte rnalExporter File "D:\applics\Python\lib\site-packages\win32com\client__init__.py", line 4 59, in ApplyTypes self.oleobj.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args), TypeError: The Python instance can not be converted to a COM object
I am aware that I can use SaveAs as a workaround, but it is much less powerful than ExportAsFixedFormat. So the question is: how can I solve the error above?
I did come across a similar problem on StackOverflow, but the solution posted there doesn't help.
I'm using Python 3.3.2 and Office 2013, under Win7 x64.
Thank you!
Solution
This is a Bug in the PowerPoint API.
Workaround: Pass the keyword argument PrintRange=None.
For details see: https://sourceforge.net/p/pywin32/bugs/339/