You could use the ontime event. Try this example.
Don't forget to change name of powerpoint file
Private m_pptApp As Object
Sub KillPPT()
If Not m_pptApp Is Nothing Then
If m_pptApp.SlideShowWindows.Count > 0 Then
' check again in 2 seconds
Application.OnTime Now() + TimeSerial(0, 0, 2), "KillPPT"
Else
m_pptApp.activepresentation.Close
m_pptApp.Quit
Set m_pptApp = Nothing
AppActivate Application.Caption
End If
End If
End Sub
Sub ShowPPT()
Dim filename As String
'Opens a PowerPoint presentation from Excel
Dim s$
Dim pres As Object
s = "C:\temp\Presentation1.pptx" '"D:\Dropbox\Jobs\NCDOT Financial Technical Assistance\Presentation1.pptx"
Set m_pptApp = CreateObject("PowerPoint.Application")
m_pptApp.Visible = True
Select Case Dir(s) <> ""
Case True
Set pres = m_pptApp.Presentations.Open(s)
pres.SlideShowSettings.Run
Application.OnTime Now() + TimeSerial(0, 0, 2), "KillPPT"
Case False
MsgBox "Could not find file!", vbCritical, s
End Select
End Sub
Bookmarks