Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: PDF VB.NET Powerpoint
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 1-Jun-12 6:48am
Comments
losmac at 1-Jun-12 11:57am
   
Which version of PP?
Shahpekan at 30-Oct-12 0:03am
   
why cannot do import microsoft.office ?

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

  Print Answers RSS
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,260


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 1 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100