Tom’s Tutorials For Excel: Running a PowerPoint Presentation From Excel

Tom’s Tutorials For Excel: Running a PowerPoint Presentation From Excel

Download this Excel workbook that runs a PowerPoint presentation.
Download this accompanying PowerPoint presentation.

Here is how you can run a PowerPoint presentation from Excel, with the below macro named “PowerPointSlideshow”. This macro is also in the downloadable workbook named “RunPowerPointExample” through a link at the top of this blog entry, which runs a slideshow from your PowerPoint presentation. A PowerPoint presentation example that accompanies this Excel workbook’s macro can also be downloaded from the above link.

When the slideshow is completed, you can hit the Esc key or click anywhere on the screen to show the presentation which will still be open. I placed notes in the macro to explain what the code is doing along the way, and to indicate where you can adjust the PowerPoint presentation’s name, path location, and slide viewing time.

The accompanying downloadable presentation contains 3 slides, each shown for 5 seconds that will look like the following 3 pictures:

Slide 1 of 3

Slide 2 of 3

Slide 3 of 3

Here’s the macro, same as in the downloadable workbook:

Sub PowerPointSlideshow()

'Declare and define String variables (modify as desired).
Dim strFilePath As String, strFileName As String, strFilePathAndName
strFilePath = "C:\YourFilePath\"
strFileName = "SlideshowTest.pptx"
strFilePathAndName = strFilePath & strFileName

'Verify that the declared PowerPoint presentation name exists
'in the declared path.
If Len(Dir(strFilePathAndName, vbDirectory)) = 0 Then
MsgBox "There is no file named ''" & strFileName & "''" & vbCrLf & _
"in the path ''" & strFilePath & "''." & vbCrLf & vbCrLf & _
"Please check your PowerPoint presentation's" & vbCrLf & _
"name, and its expected location in the path" & vbCrLf & _
strFilePath & ".", 48, "Cannot continue -- file and path not found."
Exit Sub
End If

'Declare and define Object variables.
Dim ppApp As Object, ppPres As Object
Set ppApp = CreateObject("PowerPoint.Application")
Set ppPres = ppApp.Presentations.Open(strFilePath & strFileName)

'Establish the slides' viewing time duration.
'This example is for 5 seconds.
With ppPres.slides.Range.slideshowtransition
.advanceontime = True
.advancetime = 5
End With

'Run the slide show.
ppPres.slideshowsettings.Run

'Express as True that the PowerPoint presentation was saved,
'if you want to close it without being prompted to save it.
ppPres.Saved = True

'Release the Object variables from memory.
Set ppPres = Nothing
Set ppApp = Nothing

End Sub

Share Button
Posted in Tom's Tutorials for Excel
Tags: ,
2 comments on “Tom’s Tutorials For Excel: Running a PowerPoint Presentation From Excel
  1. Dhara Patel says:

    Really trustworthy blog. Please keep updating with great posts like this one. I have booked marked your site and am about to email it to a few friends of mine that I know would enjoy reading.

    MS Excel

Leave a Reply

Your email address will not be published. Required fields are marked *

*