How to get rid of the dummy clone page?

Hi,

I'm trying to add slides to the end if new record is found in the database. I could not do so with a dummy page at the end. Otherwise, it will not work. Could you please help me with that?

My code:

Dim slds As SlidesEx = pres.Slides

slds.AddClone(pres2.Slides(0))

Dim JobNumber As String

JobNumber = Request.QueryString("JobNumber")

Dim ConnStr As String = System.Configuration.ConfigurationSettings.AppSettings("ConnStr")

Dim com As New OdbcCommand

com.Connection = New OdbcConnection(ConnStr)

com.Connection.Open()

com.CommandText = "SELECT DISTINCT ProductName, SerialNumber FROM SerialNumber JOIN JobNumber using (JobNumber) where JobNumber=?"

com.Parameters.Add("@JobNumber", OdbcType.Char).Value = JobNumber

com.ExecuteNonQuery()

Dim objDataReader0 As OdbcDataReader

objDataReader0 = com.ExecuteReader(CommandBehavior.CloseConnection)

Dim pagenumber As Integer = 0

While objDataReader0.Read()

Dim SerialNumber As String = objDataReader0("SerialNumber")

Dim shortSN As String = Right(SerialNumber, 4)

pagenumber = pagenumber + 1

Dim sldnumber As SlideEx = pres.Slides(pagenumber)

Dim SN1 As TextFrameEx = (CType(sldnumber.Shapes(0), AutoShapeEx)).TextFrame

SN1.Text = "SN" & shortSN

slds.AddClone(pres2.Slides(0))

End While

Hi Jane,

I have tried to understand the problem statement shared by you. But unfortunately, I am unable to completely understand it. Can you please share some more information about the issue along with some working code example so that I may try to help you out further.

Thanks and Regards,

Sorry for my typo. I meant I could only do so with a dummy page at the end.

Now I have changed my mind. I want to have a summary page before the looped pages (the pages populated after "While"). But the summary page is always at the end. Could you please help? I've posted the new code at following:

Dim pres As New PresentationEx("E:\report\title.pptx")

Dim pres2 As New PresentationEx("E:\report\report.pptx")

Dim sld As SlideEx = pres.Slides(0)

Dim slds As SlidesEx = pres.Slides

slds.InsertClone(1, pres2.Slides(0))

Dim JobNumber As String

JobNumber = Request.QueryString("JobNumber")

Dim ConnStr As String = System.Configuration.ConfigurationSettings.AppSettings("ConnStr")

Dim com As New OdbcCommand

com.Connection = New OdbcConnection(ConnStr)

com.Connection.Open()

com.CommandText = "SELECT DISTINCT ProductName, SerialNumber FROM SerialNumber JOIN JobNumber using (JobNumber) where JobNumber=?"

com.Parameters.Add("@JobNumber", OdbcType.Char).Value = JobNumber

com.ExecuteNonQuery()

Dim objDataReader0 As OdbcDataReader

objDataReader0 = com.ExecuteReader(CommandBehavior.CloseConnection)

Dim pagenumber As Integer = 0

While objDataReader0.Read()

Dim SerialNumber As String = objDataReader0("SerialNumber")

Dim shortSN As String = Right(SerialNumber, 4)

pagenumber = pagenumber + 1

Dim sldnumber As SlideEx = pres.Slides(pagenumber)

Dim SN1 As TextFrameEx = (CType(sldnumber.Shapes(0), AutoShapeEx)).TextFrame

SN1.Text = "SN" & shortSN

slds.AddClone(pres2.Slides(0))

End While

Hello Dear,

I have observed the code snippet shared by you and it seems to be ok. You are using AddClone() method and it clones the slide at the end of the presentation. Can you please share the generated presentation and the presentation what actually is desired. I have also observed that you have used two source presentations as well. Please also share them for necessary investigation on our end.

Thanks and Regards,

I’m using the format of title.pptx as title page, and format of report.pptx as the content pages. “report.pptx” is a one slide blank pptx file with the desired format. After cloing report.pptx then I put different content on the content pages. I want to have a summary page right after the title page. I tried insertclone and addclone. Both of them put the summary page at the end of the presentation. Please help. Thanks!

Hi Jane,

I have worked on the base of information shared by you and have generated the source and template presentations. I have used the following code snippet for your information. I have also shared the generated presentation as well for reference. Hopefully, it will help you. If you may still find any issue then please share the source and generated presentations with us as well.

Dim pth As String = "D:\\Aspose Data\\"

Dim Source As PresentationEx = New PresentationEx(pth + "Source_Pres.pptx")

Dim Template As PresentationEx = New PresentationEx(pth + "Temp_Pres.pptx")

Dim sld As SlideEx = Source.Slides(0)

Dim slds As SlidesEx = Source.Slides

Dim pagenumber As Integer = 2 ' First title and second summary slide

While pagenumber < 10

slds.InsertClone(Source.Slides.Count, Template.Slides(0))

' I am adding page number just for proof of concept

Dim shortSN As String = pagenumber + 1

Dim sldnumber As SlideEx = Source.Slides(pagenumber)

Dim SN1 As TextFrameEx = (CType(sldnumber.Shapes(0), AutoShapeEx)).TextFrame

SN1.Text = "SN" & shortSN

' slds.AddClone(pres2.Slides(0))

pagenumber = pagenumber + 1

End While

Source.Write(pth + "DemoTest2.pptx")

Thanks and Regards,

Thanks. The code works.