Results 1 to 2 of 2

Thread: VBA in Access to close all open PowerPoint presentations

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Yes, you can use VBA code in your Access database to close all open PowerPoint presentations before running your code. Here's an example of how you can achieve this:

    Sub CloseAllPowerPointPresentations()
        Dim pptApp As Object ' PowerPoint.Application
        Dim pptPres As Object ' PowerPoint.Presentation
    ' Check if PowerPoint is already open
        On Error Resume Next
        Set pptApp = GetObject(, "PowerPoint.Application")
        On Error GoTo 0
    ' If PowerPoint is open, close all presentations
        If Not pptApp Is Nothing Then
        For Each pptPres In pptApp.Presentations
            pptPres.Close
        Next pptPres
        ' Quit PowerPoint application
        pptApp.Quit
        Set pptApp = Nothing
        End If
    ' Clean up the objects
        Set pptPres = Nothing
        Set pptApp = Nothing
    End Sub
    You can call the CloseAllPowerPointPresentations subroutine at the beginning of your Access procedure to ensure that all open PowerPoint presentations are closed before continuing with your code.
    Last edited by Aussiebear; 11-02-2023 at 01:23 PM. Reason: Added code tags to supplied code

Posting Permissions

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