Reputation: 1033
Hey I am doing a reporting generate program.
I need to update certain part of some TextBox in PowerPoint (such as date).
I tried to do it with vba, but it turns out to be very complicated because once I updated the text content, I would have to re-setup all the format.
Is there an convenient way to update certain part of the TextBox without have to re-setting up all the formatting?
Upvotes: 0
Views: 308
Reputation: 14809
As you suspected, the Replace method will do what you want.
Example:
Sub ReplaceText(oRng As TextRange, sReplaceWhat As String, sWithWhat As String)
With oRng
.Characters.Replace sReplaceWhat, sWithWhat
End With
End Sub
And to test it
Sub Test()
With ActivePresentation.Slides(1).Shapes(1)
Call ReplaceText(.TextFrame.TextRange, "text", "newtext")
End With
End Sub
Upvotes: 1