Free Support Forum - aspose.com

Replacing Text in Power Point Frame

I will send my slide template via email. In this example, I have created Alternative Text = “ProductName” in the template. I also have the text “Key Product Features”, which I am trying to replace with this code:

Dim tf As TextFrame = Nothing

tf = FindTextFrame(slide, “ProductName”)

If Not (tf Is Nothing) Then

Dim FrameText As String

FrameText = tf.Text

tf.Text.Replace(FrameText, “Kilroy was here”)

End If

The problem is that the text in the output slide is NOT being replaced with “Kilroy was here”. Am I using the wrong method? Is this a bug? Please advise.
Randy Kemp

Dear Randy,

TextFrame.Text is read-only property.

Dim tf As TextFrame = Nothing
tf = FindTextFrame(slide, “ProductName”)

if Not (tf Is Nothing) Then
Dim FrameText As String
FrameText = tf.Text
tf.Paragraphs(0).Portions(0).Text.Replace(FrameText, “Kilroy was here”)
End If

Alex:
I tried this statement under the Visual Studio debugger with the slide template slide RandyPagersDraftOneSlide.ppt, but it still doesn’t replace the text. Can you try it with the PPT slide, and see if it is something with the slide template? Thanks.
Randy

I used this statement under VS debugger
tf.Paragraphs(0).Portions(0).Text.Replace(FrameText, “Kilroy was here”)
Randy

I’m sorry. It must be:

tf.Paragraphs(0).Portions(0).Text = tf.Paragraphs(0).Portions(0).Text.Replace(FrameText, “Kilroy was here”)

or without any Replace functions:

tf.Paragraphs(0).Portions(0).Text = “Kilroy was here”

Thanks, Alex. That did it. I should have anti***ted assigning the results of the operation to the replace function. I think that it is also how it works in the J2EE Java world.
Randy