I want to save Slide 1 to Slide 20 as One PPT and Slide 1 to Slide 50 as second PPT with VBA (My Master Deck has 300 Slides)

Viewed 20

I have a PPT with 300 slides and I want to save slide 1 to slide 20 as one presentation and slide 1 to slide 50 as second presentation. Can I do it with one VBA script?

Below is what I have tried, but not getting the desired result:

Option Explicit

Sub ExportingtwoPPTs()

Dim x As Long

Dim myPresentation As Presentation


Set myPresentation = Presentations.Open("C:\Users\abhishek.verma\Desktop\MasterDeck.pptx")

myPresentation.SaveAs ("C:\Users\abhishek.verma\Desktop\MasterDeck_Mini.pptx")

With myPresentation
 
    For x = .Slides.Count To 51 Step -1
        .Slides(x).Delete
    Next
End With

myPresentation.Save

myPresentation.SaveAs ("C:\Users\abhishek.verma\Desktop\MasterDeck_Mino.pptx")

With myPresentation
   
    For x = .Slides.Count To 21 Step -1
        .Slides(x).Delete
    Next
End With

myPresentation.Save


End Sub

Please note that it is not giving any error. Just that 2 PPTs are getting created with slide 1 to 50 with the names MasterDeck_Mini & MasterDeck_Mino

0 Answers
Related