close all powerpoint files from an access application

mana

Registered User.
Local time
Yesterday, 21:19
Joined
Nov 4, 2014
Messages
265
hello,

i want that if any powerpoint application is open after closing my access app all of these powerpoint files will be closed.
i found this code for excel file and i changed it for powerpoint application. but i have an error message in this pink line?
can you help me please?
thank you?

error 438: object doesn't support this property or method





Code:
Public Function test()
    Dim oApp As Object
    Dim workbook1 As Object
    
   
GoTo check
check:
Set oApp = GetApplication("powerpoint.Application")
        [COLOR=magenta]For Each workbook1 In oApp.Workbooks
[/COLOR]             'MsgBox workbook1.FullName
            'workbook1.Save
            workbook1.Close
            GoTo check
        Next workbook1
oApp.Quit
Set oApp = Nothing
End Function
Private Function GetApplication(ByVal AppClass As String) As Object
    Const vbErr_AppNotRun = 429
    On Error Resume Next
    Set GetApplication = GetObject(Class:=AppClass)
    If Err.Number = vbErr_AppNotRun _
        Then Set GetApplication = CreateObject(AppClass)
    On Error GoTo 0
End Function
 
My bet is that the Powerpoint application object doesn't contain a workbooks collection.
 
You can't just take some piece of code used for an Excel application and think it would run for Powerpoint.
In Excel you've Workbooks I don't think you've that in Powerpoint!
Try Google: close powerpoint vba
 

Users who are viewing this thread

Back
Top Bottom