Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a VB.net program that batch converts MS Word and MS Excel files to PDF’s. The VB program uses ExportasFixedFormat to create the PDF’s which works great. I’ve been asked to change the program so that it also converts MS PowerPoint files. I have gotten everything to work but there is one slight issue. When the program converts a PowerPoint file, PowerPoint displays a small form with a progress bar that shows the publishing progress. I would like to convert the PowerPoint files totally silent. I have tried using SaveAs and it also shows the progress bar. Neither Excel or Word shows the progress bar. Does anyone have any ideas on how to do this?

VB
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
Posted
Comments
Maciej Los 1-Jun-12 11:57am    
Which version of PP?
Shahpekan 30-Oct-12 0:03am    
why cannot do import microsoft.office ?
Whictopis 31-May-17 5:11am    
Just for a consideration, you could avoid the usage of excel's interop automation and word's interop automation by using libraries that can enable you to do these tasks.
For instance see here how to convert:
- powerpoint to pdf in c#
- word to pdf in c#
- excel to pdf in c#

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900