Adding Text To Existing Placeholders


I looked at your documentation on the web and saw the followign code along with the Aspose ppt file

Dim pres As Presentation = New Presentation(MapPath(".") + "\\App_Documents\Template\Aspose.ppt")

'Accessing a slide using its slide position
Dim slide As Slide = pres.GetSlideByPosition(1)

'Accessing the first placeholder in the slide and typecasting it as a text holder
Dim th As TextHolder = CType(slide.Placeholders(0), TextHolder)

'Comparing the text in text holder to find a specific text holder. If the 'text matches then replace the text inside that text holder
If th.Text.Equals("Aspose.Slides") Then
th.Paragraphs(0).Portions(0).Text = "Welcome to Aspose.Slides"
End If

'Writing the presentation as a PPT file
pres.Write(MapPath(".") + "\\App_Documents\Template\modified.ppt")

This works file but I want to have 4 differnet placeholders that I can add text to so I opened the ppt file, cut and paste the existing placeholder and then tried the following in an attempt to add text to the second placeholder

Dim th2 As TextHolder = CType(slide.Placeholders(1), TextHolder)

If th2.Text.Equals("Aspose.Slides") Then
th.Paragraphs(0).Portions(0).Text = "Welcome to Aspose.Slides 2"
End If

When I run the tool it basically cant find the additional placeholders I added to the Aspose ppt so I would mnassivly appreciate it if you could tell me where I am going wrong



Dear Alan

When you cut/paste or copy/paste, they don’t remain placeholders or textholders, they become textframes.

The only way to add placeholders is using the Slide Layout feature in MS-PowerPoint or Aspose.Slides APIs, for example


So, you will find the rest of your two textframe in Slide.Shapes collection.

See this post, the code there iterates all shapes on slide and find the textholders and textframes and change their text. It is in C#, but hopefully it will be helpful for you.