OfficeTips Home || VBA Section || General Section ||  Download Section  ||  Privacy Policy

Start a slide show and monitor it from an external application

  The example makes use of late binding.


' --------------------------------------------------------------------------------
' Copyright 1999-2011, Shyam Pillai, All Rights Reserved.
' --------------------------------------------------------------------------------
' You are free to use this code within your own applications, add-ins,
' documents etc but you are expressly forbidden from selling or
' otherwise distributing this source code without prior consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
' --------------------------------------------------------------------------------

Option Explicit
Sub AutomatePoint()
    Dim oPPTApp As Object
    Dim oPPTPres As Object
    Dim PresPath As String
    On Error Resume Next
    PresPath = "D:\Presentation\Demo.ppt"
    Set oPPTApp = CreateObject("PowerPoint.Application")
    If Not oPPTApp Is Nothing Then
        With oPPTApp
            Set oPPTPres = .Presentations.Open(PresPath, , , False)
            If Not oPPTPres Is Nothing Then
                oPPTPres.SlideShowSettings.Run
                Do While .SlideShowWindows.Count > 0
                    DoEvents
                Loop
            Else
                MsgBox "The code could not open the specified file." & _
                        "Check if the file is present at the location.", _
                        vbCritical + vbOKOnly, "PowerPoint Automation Example"
            End If
        End With
    Else
        MsgBox "The code failed to instantiate PowerPoint session.", _
                vbCritical + vbOKOnly, "PowerPoint Automation Example"
    End If
    Set oPPTPres = Nothing
    DoEvents
    oPPTApp.Quit
    DoEvents
    Set oPPTApp = Nothing
    MsgBox "The PowerPoint session was terminated.", _
            vbInformation + vbOKOnly, "PowerPoint Automation Example"
End Sub
 

 


 

 
   
 

Copyright 1999-2011 (c) Shyam Pillai. All rights reserved.