Imports Microsoft.office.Interop.PowerPoint Module PowerPointToPDF Public Function ConvertPowerPointToPDF(ByVal InputFilePath As String, ByVal OutputFilePath As String) As Integer Dim Errors As Integer = 0 Dim PPApplication As ApplicationClass = Nothing Dim PPDoc As Presentation = Nothing Try ' Start an instance of PowerPoint PPApplication = New ApplicationClass() 'PPApplication.Visible = True ' Open the source document. PPDoc = PPApplication.Presentations.Open(InputFilePath, WithWindow:=False) PPDoc.SaveAs(OutputFilePath, PpSaveAsFileType.ppSaveAsPDF) 'PPDoc.ExportAsFixedFormat(OutputFilePath, PpFixedFormatType.ppFixedFormatTypePDF, PpFixedFormatIntent.ppFixedFormatIntentScreen, Microsoft.Office.Core.MsoTriState.msoCTrue, PpPrintHandoutOrder.ppPrintHandoutHorizontalFirst, PpPrintOutputType.ppPrintOutputBuildSlides, Microsoft.Office.Core.MsoTriState.msoFalse, , , , False, False, False, False, False) Catch ex As Exception MsgBox(ex.Message) Errors = 1 Finally ' Close and release the Document object. If Not PPDoc Is Nothing Then PPDoc.Close() PPDoc = Nothing End If ' Quit PowerPoint and release the ApplicationClass object. If Not PPApplication Is Nothing Then PPApplication.Quit() PPApplication = Nothing End If GC.Collect() GC.WaitForPendingFinalizers() GC.Collect() GC.WaitForPendingFinalizers() End Try Return Errors End Function End Module
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)