I need to find and replace a string in PPT. But the length of the string will vary and PPT does not allow wildcard searches like Word. I need to find every string that begins with <REF
and end with >
. In Word I would search for <REF*>
. How do I do this in PPT? Here is what I have so far, but this only finds some of the strings. Please help!
Function FindAndReplace(s As String, replacementText As String) As String
Const LEFT As String = "<REF"
Const RIGHT As String = ">"
Dim temp As String
temp = s
Dim iPos As Integer
iPos = 1
Dim iStart As Integer, iEnd As Integer
Do
iPos = InStr(iPos, temp, LEFT)
If iPos = 0 Then
FindAndReplace = temp
Exit Function
End If
iStart = iPos
iEnd = InStr(iStart, temp, RIGHT)
If iEnd = 0 Then
FindAndReplace = temp
Exit Function
End If
Dim targetText As String
iEnd = iEnd + 1
targetText = Mid(temp, iStart, iEnd - iStart)
temp = Replace(temp, targetText, replacementText)
iPos = iPos + Len(LEFT) + Len(targetText) + Len(RIGHT)
If iPos >= Len(temp) Then Exit Do
Loop
FindAndReplace = temp
End Function