PowerPoint 2007 SP2, ExportAsFixedFormat in PowerShell?

血红的双手。 提交于 2019-12-07 15:10:48
Winand

I've come across the same problem in Python. Try specifying PrintRange argument as said in solution by Stefan Schukat:

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.

Source: Type mismatch when using export fuction of PowerPoint 2007


I don't know PowerShell at all but have worked out a working example:

$p.ActivePresentation.PrintOptions.Ranges.Add(1,1)
$r = $p.ActivePresentation.PrintOptions.Ranges.Item(1)
$document.ExportAsFixedFormat('D:\\ps.pdf', 2, 1, 0, 1, 1, 0, $r)

This isn't a full solution, but exporting is done. It somehow exports full presentation, not only slide no. 1, as I thought. P.S. Oh. Here's the same solution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!