Click here to Skip to main content
14,268,370 members
Rate this:
Please Sign up or sign in to vote.
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?

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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100