Powerpoint - How to delete slide based on text value

Hi @lbowen
I just tried a LLM code and it works, Use invoke code

Dim pptApp As Microsoft.Office.Interop.PowerPoint.Application = New Microsoft.Office.Interop.PowerPoint.Application()
Dim pptPresentation As Microsoft.Office.Interop.PowerPoint.Presentation = pptApp.Presentations.Open("Give Full file path", WithWindow:=MsoTriState.msoFalse)
Dim slideDeleted As Boolean = False

Try
    ' Loop through all slides in the presentation
    For i As Integer = pptPresentation.Slides.Count To 1 Step -1
        Dim slide As Microsoft.Office.Interop.PowerPoint.Slide = pptPresentation.Slides(i)
        ' Search for the text in the slide
        Dim containsText As Boolean = False
        For Each shape As Microsoft.Office.Interop.PowerPoint.Shape In slide.Shapes
            If shape.HasTextFrame = MsoTriState.msoTrue AndAlso
               shape.TextFrame.HasText = MsoTriState.msoTrue AndAlso
               shape.TextFrame.TextRange.Text.Contains("Text to delete") Then
                containsText = True
                Exit For
            End If
        Next
        ' Delete the slide if the text is found
        If containsText Then
            slide.Delete()
            slideDeleted = True
        End If
    Next
    ' Save and close the presentation
    pptPresentation.Save()
    pptPresentation.Close()
Catch ex As Exception
    Throw New Exception("Error while deleting slide: " & ex.Message)
Finally
    pptApp.Quit()
End Try

Please import the below namespaces
Microsoft.Office.Interop.PowerPoint
Microsoft.Office.Core

Hope this helps!