Difficulty Upgrading from Aspose.PowerPoint

Greetings,

I'm trying to upgrade from Asose.PowerPoint to Aspose.Slides and I'm stuck :(. I have a .PPT file that is my template and below is the code I used to use to set various field values. This syntax doesn't work with Aspose.Slides but I can't seem to figure out the problem. Attached is the .ppt file I'm trying to use.

Here's the syntax:

Dim License As New Aspose.Slides.License

License.SetLicense("Aspose.Slides.lic")

Using fis As System.IO.FileStream = New System.IO.FileStream(MapPath(".") + "\\ai2.ppt", IO.FileMode.Open, System.IO.FileAccess.Read)

''Dim fis As System.IO.FileStream = New System.IO.FileStream(MapPath(".") + "\\ait2.ppt", IO.FileMode.Open, System.IO.FileAccess.Read)

Dim pres As Presentation = New Presentation(fis)

fis.Close()

Dim slides As Slides = pres.Slides

Dim Shapes As Shapes

Dim tf As TextFrame

Shapes = slides(0).Shapes

'AINumber

tf = Shapes(0).TextFrame

If tf Is Nothing Then

lblErr.Text = "Nothing!!!"

Exit Sub

Else

tf.Paragraphs(0).Portions(0).Text = AINumber

tf.Paragraphs(0).Portions(0).FontBold = True

tf.Paragraphs(0).Portions(0).FontHeight = 18

tf.Paragraphs(0).Alignment = TextAlignment.Center

tf.Paragraphs(0).Portions(0).Text = AINumber

End If

For some reason the variable tf is always nothing :(.

Dear Zack,

I have tried to work with the code snippet and presentation file shared by you and have found the code snippet correct. The issue is that there is no text associated with any of text frames inside the shared presentation and that is why you are always getting "Nothing" from text frame. I have modified the code snippet a little and added some text in presentation text frame. The code is working fine with that. Please find the code snippet below and modified presentation in the attachment. Please share with us, if the problem still persist.

Dim License As New Aspose.Slides.License

License.SetLicense("Aspose.Slides.lic")

Dim pres As Presentation = New Presentation("D:\Aspose Data\ai.ppt")

' fis.Close()

Dim slides As Slides = pres.Slides

Dim shapes As Shapes

Dim shape As Shape

Dim tf As TextFrame

shapes = slides(0).Shapes

shape = shapes(1)

'AINumber

tf = shape.TextFrame

If tf Is Nothing Then

sFile = "Nothing!!!"

Exit Sub

Else

tf.Paragraphs(0).Portions(0).Text = AINumber

tf.Paragraphs(0).Portions(0).FontBold = True

tf.Paragraphs(0).Portions(0).FontHeight = 18

tf.Paragraphs(0).Alignment = TextAlignment.Center

tf.Paragraphs(0).Portions(0).Text = AINumber

End If

Thanks and Regards,

Thanks for the reply but I don't understand the need to have any text in the PPT file for things to work. Basically the file is an empty template and we populate it with data from the database. I suppose in my sample I should have changed it to tf.Paragraphs(0).Portions(0).Text = AINumber to something like tf.Paragraphs(0).Portions(0).Text = "Testing 1 2 3".

If I can no longer access a textframe in a PPT template because it does not contain any text how do you recommend I create the PPT file? Do I need to manually create text areas on a blank slide? What's the best approach to populate a PPT slide with data from a database?

Hello Dear,

You can add the text inside the empty text frame and can even populate the data inside text frame from database. Please follow this documentation link to see how to add the text frame and adding text to it. If you still feel issue then please share with us.

Thanks and Regards,

Sorry for the delay in replying but I don't understand your reply. If I already have a slide template that has all of the text areas defined in it (attached in my original post) why do I need to add a new textframe? I guess I just don't understand how to use the component after it switched from aspose.PPT to aspose.Slides. It seems to me this upgrade has taken a step backwards.

Based on the link you provided it appears I have to manually add a textframe to the slide and then populate it with data. If that's the way you have to do it then having a template slide is of no use.

Since it looks like I'll have to create the slide manually everytime can you tell me an easy way to determine the locations of the existing textboxes in the sample I provided so I'll know what size textframes to manually create.

Hello Dear,

I feel sorry for your inconvenience. I have worked with the template PPT file shared by you using Aspose.Slides for .NET 4.3.0 and when verifying the TextFrame to "Nothing" is not returned. Can you please verify this on you end. Hopefully the things might work for you.

Thanks and Regards,

I can't get it to work regardless of what I try. Attached is a project that demonstrates the error. Please try it and let me know if you get the "Nothing" error like I'm getting.

Hello Dear,

I have again worked with the presentation file shared by you. I have observed that you are trying to access the text frame of shape(0). Since, Shape(0) is a picture frame and has no text frame so "Nothing" is returned for that. However, if you use the shape other the Shape(0), you will be able to access the text frame. I have just made following modification in your code snippet and it worked for me.

tf = Shapes(1).TextFrame

For your kind reference, I have also attached the generated presentation.

Thanks and Regards,

Thanks for all of the help. I have it working now.