+ Reply to Thread
Results 1 to 9 of 9

Open PowerPoint in slideshow mode from Excel

Hybrid View

  1. #1
    Registered User
    Join Date
    11-30-2012
    Location
    North Carolina
    MS-Off Ver
    Office 365
    Posts
    61

    Open PowerPoint in slideshow mode from Excel

    An unusual question but I am hoping the experts here can help out.

    I have an Excel workbook that models an cost allocation process. There is also a PowerPoint presentation that explains this process. I want, in various worksheets of the workbook, place a command button that will open the PowerPoint in presentation mode. I can set the slides for time. After the PowerPoint slideshow is over, I want to exit PowerPoint and return to Excel.

    I have written VBA code that will successfully open the PowerPoint. However, I cannot figure out if it is possible to open in slideshow view, rather than sorter view. Also, I do not know how to allow the PowerPoint to run and close, then return to Excel.

    My code at present is:

    Sub Open_PowerPoint()
    
    'Opens a PowerPoint presentation from Excel
    
    Dim objPPT As Object, s$
    Dim myPresentation As PowerPoint.Presentation
    
    s = "D:\Dropbox\Jobs\NCDOT Financial Technical Assistance\Presentation1.pptx"
    Set objPPT = CreateObject("PowerPoint.Application")
    objPPT.Visible = True
    
    Select Case Dir(s) <> ""
        Case True
            objPPT.Presentations.Open s
    
        Case False
            MsgBox "Could not find file!", vbCritical, s
    End Select
    
    End Sub
    Any help will be appreciated.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Open PowerPoint in slideshow mode from Excel

    to run the slideshow you can use

    Select Case Dir(s) <> ""
        Case True
            Set myPresentation = objPPT.Presentations.Open(s)
            myPresentation.SlideShowSettings.Run
        Case False
            MsgBox "Could not find file!", vbCritical, s
    End Select
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    11-30-2012
    Location
    North Carolina
    MS-Off Ver
    Office 365
    Posts
    61

    Re: Open PowerPoint in slideshow mode from Excel

    Andy:

    Perfect; that worked. Another question...after the PowerPoint runs through it's timed settings, is there a way to switch back to Excel? Some type of timer that would automatically trigger switching back to Excel after say, 30 seconds (the time of 6, 5-second slides)?

    Thanks.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Open PowerPoint in slideshow mode from Excel

    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

  5. #5
    Registered User
    Join Date
    11-30-2012
    Location
    North Carolina
    MS-Off Ver
    Office 365
    Posts
    61

    Re: Open PowerPoint in slideshow mode from Excel

    Andy:

    Thanks for the reply. Changed the name of the PowerPoint and placed the code in a new module. The OnTime function is not killing the Powerpoint. When I manually exit the PowerPoint by hitting escape, a runtime error appears on the KillPPT() sub.

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Open PowerPoint in slideshow mode from Excel

    I only get an error if the powerpoint is shutdown by the user.
    The error messages is

    Application.ActivePresentation : Invalid request. There is no active presentation.


    This tweak will check for open presentation
    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
                If m_pptApp.presentations.Count > 0 Then
                    m_pptApp.activepresentation.Close
                End If
                m_pptApp.Quit
                Set m_pptApp = Nothing
                AppActivate Application.Caption
            End If
        End If
        
    End Sub

  7. #7
    Registered User
    Join Date
    11-30-2012
    Location
    North Carolina
    MS-Off Ver
    Office 365
    Posts
    61

    Re: Open PowerPoint in slideshow mode from Excel

    Andy:

    That removed the error; thanks. After the slides, the PowerPoint show ends, I have to click ESC in order to get back to Excel. So I a now just missing the automatic return to Excel.

  8. #8
    Registered User
    Join Date
    11-30-2012
    Location
    North Carolina
    MS-Off Ver
    Office 365
    Posts
    61

    Re: Open PowerPoint in slideshow mode from Excel

    Here is a link to the file:

    https://www.dropbox.com/s/xxt2nar4fq...del4.xlsm?dl=0

    The code is in Module 2.

  9. #9
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Open PowerPoint in slideshow mode from Excel

    My pptx file shows and I can make my way through the slideshow. Once I get passed the 'click to end slide show' screen the Killppt routine executes within a couple of seconds to shutdown powerpoint and return focus to Excel.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Update the slide master from Slideshow Mode and refresh current slide
    By CoolkcaH in forum PowerPoint Programming
    Replies: 0
    Last Post: 05-02-2017, 07:10 AM
  2. Replies: 1
    Last Post: 06-09-2016, 12:05 PM
  3. Excel macro to open a specific slide in a powerpoint slideshow
    By christopher@groth.cc in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-10-2014, 08:30 AM
  4. Replies: 13
    Last Post: 01-11-2013, 04:46 PM
  5. Macro to "refresh data" in a excel linked chart in powerpoint during the slideshow
    By Gordon Wan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-10-2012, 01:44 PM
  6. Replies: 2
    Last Post: 06-19-2012, 06:54 PM
  7. Excel appear as Powerpoint Slideshow
    By mattsgr1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-12-2007, 08:42 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1