I am currently trying to create a new PPT presentation by deleting unwanted slides from a presentation. The slides - and their slide numbers - are being selected in the first column of a table I have in Excel.
I tried to solve this problem by taking another table instead of the one I want to use and it worked. For some reason it seems not work with the "Table 3".
Sub CreatingNewPresentation() Dim Destination1PPT As String Dim ppApp As PowerPoint.Application Dim ppPres As PowerPoint.Presentation Dim ppSlide As PowerPoint.Slide Dim myTable As ListObject Dim TempArray As Variant Dim x As Long If MsgBox("This can take a while", vbOKCancel + vbExclamation, "Creating new presentation") = vbCancel Then Exit Sub Else Set ppApp = CreateObject("PowerPoint.Application") Destination1PPT = "C:\Users\Steffen\Desktop\Test2\1.pptx" Set ppPres = ppApp.Presentations.Open(Destination1PPT) ppApp.Visible = True ppApp.Activate Set myTable = ActiveSheet.ListObjects("Table3") TempArray = myTable.ListColumns(1).DataBodyRange For x = ppApp.ActivePresentation.Slides.Count To 1 Step -1 If IsError(Application.Match(x, TempArray, False)) Then ppApp.ActivePresentation.Slides(x).Delete End If Next End If End Sub
I expect the code to open the presentation and delete all slides except the ones I store in "Table3" - column 1. What it does instead is just open the presentation and nothing else. There is no error message.