Quantcast
Channel: General Office Development forum
Viewing all articles
Browse latest Browse all 2257

PowerPoint error using ExportAsFixedFormat2 function in PowerShell

$
0
0

Hi expert,

Apologize if this is not the right place for this question.

I am writing some PowerShell script to export a pptx file to pdf, below is part of my code,

Add-Type -AssemblyName Microsoft.Office.Interop.PowerPoint
$Powerpoint = New-Object -ComObject Powerpoint.Application
$Presentation = $Powerpoint.Presentations.Open($templateFilePath, [Microsoft.Office.Core.MsoTriState]::msoTrue, [Microsoft.Office.Core.MsoTriState]::msoTrue)


$intent = [Microsoft.Office.Interop.PowerPoint.PpFixedFormatIntent]::ppFixedFormatIntentPrint
$Presentation.ExportAsFixedFormat2($filePathPdf, [Microsoft.Office.Interop.PowerPoint.PpFixedFormatType]::ppFixedFormatTypePDF, $intent)

But I receive below error in ExportAsFixedFormat2() function, 

Exception setting "ExportAsFixedFormat2": Cannot convert the "ppFixedFormatIntentPrint" value of type "PpFixedFormatIntent" to type "Object".
At C:\Users\ps\Merge-PowerPointPresentation.ps1:232 char:13
+             $NewPresentation.ExportAsFixedFormat2($filePathPdf, [Micr ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : RuntimeException

How to make it work?

Thanks,

Michael


Viewing all articles
Browse latest Browse all 2257

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>