How to split a slide from a presentation using VBA or Apple script

How to split a slide from a presentation using VBA or Apple script. previously i used a VBA code to achieve the same but in powerpoint 16.13.1 I am getting an error as "Mac PPT does not support opening file in window less mode." and it was working on previous versions of PowerPoint.
Sub SaveSlide(lSlideNum As Long, sFileName As String)

    Dim oTempPres As Presentation
    Dim x As Long

    ActivePresentation.SaveCopyAs sFileName
    ' open the saved copy windowlessly
    Set oTempPres = Presentations.Open(sFileName, , , False)

    For x = 1 To lSlideNum - 1
        oTempPres.Slides(1).Delete
    Next

    ' What was slide number lSlideNum is now slide 1
    For x = oTempPres.Slides.Count To 2 Step -1
        oTempPres.Slides(x).Delete
    Next

    oTempPres.Save
    oTempPres.Close

End Sub

Open in new window


In the above code I am getting error in this line
 Set oTempPres = Presentations.Open(sFileName, , , False)

Open in new window


Please help me.
Irshad KASoftware EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jamie GarrochPowerPoint Consultant & DeveloperCommented:
The current version of PowerPoint:mac 2016 does not support opening presentations in windowless mode:

PowerPoint:mac 2016 windowless mode error
So, you'll need to use a workaround. What about opening with a window and then minimising that window?

Sub SaveSlide(lSlideNum As Long, sFileName As String)

    Dim oTempPres As Presentation
    Dim x As Long

    ActivePresentation.SaveCopyAs sFileName
    ' open the saved copy windowlessly
    Set oTempPres = Presentations.Open(sFileName, , , True)
    oTempPres.Windows(1).WindowState = ppWindowMinimized

    For x = 1 To lSlideNum - 1
        oTempPres.Slides(1).Delete
    Next

    ' What was slide number lSlideNum is now slide 1
    For x = oTempPres.Slides.Count To 2 Step -1
        oTempPres.Slides(x).Delete
    Next

    oTempPres.Save
    oTempPres.Close

End Sub

Open in new window


Note that due to Apple's sandbox requirement, you will have to expect the user to Grant Access to a folder if you are manipulating files outside of the sandbox environment which is contained here:

~Library/Group Containers/UBF8T346G9.Office/
1
Irshad KASoftware EngineerAuthor Commented:
Thanks @Jamie Garroch I will try this.
And is there any other way around to split  all slides from a presentation to individual presentations.
Again, thanks for your help.
0
Jamie GarrochPowerPoint Consultant & DeveloperCommented:
There are many methods you could use to split a presentation into multiple files e.g. saving a copy of the file as in your example, copy/pasting individual slides from source file to target file or deleting slides from the source before saving and then undeleting. All of them require you to open the source presentation.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apple OS

From novice to tech pro — start learning today.