+ Reply to Thread
Results 1 to 2 of 2

Exit powerpoint after running macro

Hybrid View

  1. #1
    Registered User
    Join Date
    08-13-2014
    Location
    seattle
    MS-Off Ver
    2010
    Posts
    30

    Exit powerpoint after running macro

    Hi guys,

    I'm trying to find a code in excel vba to exit powerpoint after my macro runs without saving it.

    Thanks,

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Exit powerpoint after running macro

    Hi nguyenal07,

    Some of the following code may help you:
    Sub RunPowerPointSlideShowFromExcel()
    
      Const POWERPOINT_SHOWMINIMIZED = 2
    
      Dim ppt As Object
      Dim pptFile As Object
      Dim sPowerPointPathAndFileName As String
      Dim iSlideNumber As Integer
      
      'Change the following line for your PowerPoint folder and file name
      sPowerPointPathAndFileName = ThisWorkbook.Path & "\" & "ExcelForumPowerPointAutomation2.ppt"
      iSlideNumber = 2
    
      Set ppt = CreateObject("PowerPoint.Application")
      ppt.Visible = True
      Set pptFile = ppt.Presentations.Open(Filename:=sPowerPointPathAndFileName)
    
    
      With pptFile.SlideShowSettings
        .ShowType = 3   '3 = ppShowTypeKiosk
        '.ShowType = 1   '1 = ppShowTypeSpeaker
        
        .RangeType = 1   '1 = ppShowAll
        
        .ShowWithAnimation = msoCTrue
        .LoopUntilStopped = msoFalse
        .AdvanceMode = 2 '2 = ppSlideShowUseSlideTimings
        .Run
      End With
      
      
      'I know of no way to know when the slide show is completed unless:
      'a. You control all the slides from the Excel Macro
      'b. Excel/PowerPoint communicate and PowerPoint lets Excel know that the slide show has completed
      
      
      'Minimize the PowerPoint Window
      If Not ppt Is Nothing Then
        ppt.WindowState = POWERPOINT_SHOWMINIMIZED
      End If
      
      'Fool Powerpoint into thinking that changes to the PowerPoint file (if any) were saved
      'Close the powerpoint presentation (file)
      If Not pptFile Is Nothing Then
        pptFile.Saved = True
        pptFile.Close
      End If
      
      'Quit the PowerPoint application
      If Not ppt Is Nothing Then
        ppt.Quit
      End If
      
      'Clear object pointers
      Set ppt = Nothing
      Set pptFile = Nothing
        
    End Sub
    Lewis

+ 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. [SOLVED] Force the running of a Macro on Spreadhseet exit
    By scaffdog845 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-17-2012, 02:49 PM
  2. disabling exit button in window or running macros on shutdown
    By LAazsx in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-31-2010, 05:16 AM
  3. Exit a running macro elegantly
    By kencoburn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-27-2008, 11:24 AM
  4. running macro at save/close/exit
    By Pedro in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-03-2006, 08:40 AM
  5. [SOLVED] Running a Powerpoint Macro from Excel
    By smonczka in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-15-2005, 05:05 PM

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