1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| Private Sub PrintPowerPointPresentation(strFilePath As String)
' Run Microsoft PowerPoint as COM-server
On Error Resume Next
Dim App As Object
Dim Presentation As Object
Dim nSlides As Long
strFilePath = "C:\test.ppt"
Set App = CreateObject("PowerPoint.Application")
' Open presentation from file
Err = 0 ' Clear GetLastError() value
Set Presentation = App.Presentations.Open(strFilePath, 1, 1, 0)
If Err = 0 Then
' Get number of slides in the presentation
nSlides = Presentation.Slides.Count
If nSlides > 0 Then
' Print all slides from the presentation
Presentation.PrintOptions.PrintInBackground = 0
Call Presentation.PrintOut(0, nSlides, 0, 1, 0)
End If
' Close the presentation
Call Presentation.Close
Set Presentation = Nothing
End If
' Close Microsoft PowerPoint
Call App.Quit
Set App = Nothing
End Sub |