Results 1 to 5 of 5

Thread: Find and Replace for all instances of "Find" list

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Banned VBAX Newbie
    Joined
    Feb 2024
    Posts
    2
    Location
    Quote Originally Posted by Raybob View Post
    I am trying to run a find/replace using arrays, and it works, but only for the first instances on each slide. I have a slide title with duplicate words, but only the first is replaced, so I'm hoping for some help to get both words replaced.
    Thanks!

        'LOOP THROUGH EACH SLIDE
        For Each sld In objPPT.ActivePresentation.Slides
            For Y = LBound(FindArray1) To UBound(FindArray1)
                fnd = FindArray1(Y)
                rplc = ReplaceArray1(Y)
                For Each shp In sld.Shapes
                    If shp.HasTextFrame Then
                        If shp.TextFrame.HasText Then
                            Set TxtRng = shp.TextFrame.TextRange.Find(fnd, 0, True, WholeWords:=msoTrue)
                            If Not TxtRng Is Nothing Then
                                Do
                                    Set tmprng = TxtRng.Replace(FindWhat:=fnd, ReplaceWhat:=rplc, WholeWords:=True, MatchCase:=True)
                                Loop While Not tmprng Is Nothing
                            End If
                        End If
                    End If
                Next shp
            Next Y
        Next sld

    Thanks for sharing it with us!
    Last edited by Aussiebear; 03-22-2024 at 11:58 PM. Reason: Removed spam

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •