Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find and replace a string in powerpoint using VBA

Tags:

powerpoint

vba

I would like to replace the word "hello" with "world" on slide 1 of the ppt. How can I do that using VBA script.

like image 822
Rahul Dagli Avatar asked Oct 27 '25 08:10

Rahul Dagli


1 Answers

Sub findAndReplaceText()
Dim sld As Slide
Set sld = ActivePresentation.Slides(1)
Dim shp As Shape
For Each shp In sld.Shapes
If shp.HasTextFrame Then
    If shp.TextFrame.HasText Then
        shp.TextFrame.TextRange.Text = Replace(shp.TextFrame.TextRange.Text, "hello", "world")
    End If
End If
Next shp
End Sub

Reference: https://www.youtube.com/watch?v=BYfKvVmtAGE

like image 116
Rahul Dagli Avatar answered Oct 29 '25 08:10

Rahul Dagli