Delete blank slide in powerpoint from vb.net

Hello,
I have a template to export pictures on a powerpoint template. The vb.net code adds slides to the template depending on the number of pictures to be exported. How can i delete the blank slides.
This the code I am using
 Private Sub AddSlides()
        Dim intCurrSlide As Integer = ppPrsn.Slides.Count
        Dim currSlide As PowerPoint.Slide = ppPrsn.Slides(intCurrSlide)
        Dim objShape As PowerPoint.Shape = Nothing
        Dim pptLayout As Microsoft.Office.Interop.PowerPoint.CustomLayout
        pptLayout = ppPrsn.Slides(1).CustomLayout
        Dim length = l + 7
        Dim top = t + 10
        For i = 0 To 47

            pptLayout.Shapes.AddPlaceholder(PowerPoint.PpPlaceholderType.ppPlaceholderPicture, length, top, 75, 101)
            length = length + 78
            If i = 11 Then
                length = 10
                top = top + 130
            ElseIf i = 23 Then
                length = 10
                top = top + 130
            ElseIf i = 35 Then
                length = 10
                top = top + 130

            End If

        Next
        If ppPrsn.Slides.Count = 2 Then
            Dim slide As PowerPoint.Slide
            slide = ppPrsn.Slides.AddSlide(ppPrsn.Slides.Count, pptLayout)
        End If

        FlgSlideCreated = True

    End Sub

Open in new window


This code clears the placeholders :

  Private Sub ClearPictureBoxes(ByVal parent As PowerPoint.Presentation)
        Try
            If IsNothing(parent) = True Then
                Exit Sub
            End If
        Catch ex As Exception

        End Try
        Sld = ppPrsn.Slides(2) 'pass slide number
        Dim i As Integer
        For Each oSlide In ppPrsn.Slides
            For i = oSlide.Shapes.Count To 1 Step -1
                For Each shp In Sld.Shapes
                    'MessageBox.Show(shp.name)

                    'MessageBox.Show(shp.type)

                    If shp.Type = 14 Then 'msoTextBox
                        ' MsgBox(shp.PlaceholderFormat.ContainedType)
                        If (shp.PlaceholderFormat.ContainedType) = 1 Then
                            shp.delete
                            Application.DoEvents()
                        End If


                    ElseIf shp.Type = 17 Then
                        If (shp.hastextframe) = True Then
                            If shp.textframe.textrange.text = String.Empty Then
                                shp.delete
                                Application.DoEvents()
                            End If
                        End If
                    Else
                        shp.delete
                        Application.DoEvents()
                    End If

                Next
            Next i
        Next oSlide





    End Sub

Open in new window


Any improvement in the code and suggestion on how to delete blank slide is appreciated.

Thanks
RIASAsked:
Who is Participating?
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.

Rgonzo1971Commented:
Hi,

pls try
Private Sub DeleteBlankSlides(ByVal parent As PowerPoint.Presentation)
        Try
            If IsNothing(parent) = True Then
                Exit Sub
            End If
        Catch ex As Exception

        End Try
        Dim i As Integer

        For i = ppPrsn.Slides To 1 Step -1
            Sld = ppPrsn.Slides(i)
            If Sld.Shapes.Count = 0 Then
                Sld.Delete
                Application.DoEvents()
            End If
        Next i
End Sub

Open in new window

Regards
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RIASAuthor Commented:
Thanks , will try and brb .
0
RIASAuthor Commented:
Thanks! Worked like charm.
I have couple of questions on powerpoint interface with vb.net .Please check my new questions.
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
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.