J
John Svendsen
Hi All:
Could I have done something wrong, or is this behavior abnormal?
- open a new presentation in Powerpoint 2007 (not earlier versions),
- add a Text Box and write in the text below:
"this test was a blind with 100 interviews"
- run the code below (from Powerpoint's VBA Help):
It keeps on replacing "ad infinitum" when it shouldn't...
TIA, JS
Sub ReplaceText_MSO()
Dim oSld As Slide
Dim oShp As Shape
Dim oTxtRng As TextRange
Dim oTmpRng As TextRange
Set oSld = Application.ActivePresentation.Slides(1)
For Each oShp In oSld.Shapes
Set oTxtRng = oShp.TextFrame.TextRange
Set oTmpRng = oTxtRng.Replace(FindWhat:="blind", Replacewhat:="blind
test", WholeWords:=True)
Do While Not oTmpRng Is Nothing
Set oTxtRng = oTxtRng.Characters(oTmpRng.Start + oTmpRng.Length,
oTxtRng.Length)
Set oTmpRng = oTxtRng.Replace(FindWhat:="blind",
Replacewhat:="blind test", WholeWords:=True)
Loop
Next oShp
End Sub
Could I have done something wrong, or is this behavior abnormal?
- open a new presentation in Powerpoint 2007 (not earlier versions),
- add a Text Box and write in the text below:
"this test was a blind with 100 interviews"
- run the code below (from Powerpoint's VBA Help):
It keeps on replacing "ad infinitum" when it shouldn't...
TIA, JS
Sub ReplaceText_MSO()
Dim oSld As Slide
Dim oShp As Shape
Dim oTxtRng As TextRange
Dim oTmpRng As TextRange
Set oSld = Application.ActivePresentation.Slides(1)
For Each oShp In oSld.Shapes
Set oTxtRng = oShp.TextFrame.TextRange
Set oTmpRng = oTxtRng.Replace(FindWhat:="blind", Replacewhat:="blind
test", WholeWords:=True)
Do While Not oTmpRng Is Nothing
Set oTxtRng = oTxtRng.Characters(oTmpRng.Start + oTmpRng.Length,
oTxtRng.Length)
Set oTmpRng = oTxtRng.Replace(FindWhat:="blind",
Replacewhat:="blind test", WholeWords:=True)
Loop
Next oShp
End Sub