Menu

#339 Type mismatch when using export fuction of PowerPoint 2007

closed-works-for-me
nobody
com (105)
5
2014-08-26
2007-11-02
Mustafa
No

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
>>>

Discussion

  • Mustafa

    Mustafa - 2007-11-02

    Example python script

     
  • Mark Hammond

    Mark Hammond - 2007-11-03

    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

     
  • Stefan Schukat

    Stefan Schukat - 2007-11-05

    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.

     
  • Mustafa

    Mustafa - 2007-11-06

    Logged In: YES
    user_id=1525528
    Originator: YES

    It works !!!

     
  • Mustafa

    Mustafa - 2007-11-06
    • labels: --> com
    • status: open --> closed-works-for-me
     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.