Possible problem with TextRange.Replace Method in Powerpoint 2007 ???

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
 
J

John Wilson

Works fine here. It does error (for me) with Shyam's suggested mod for 2007
Do While oTmpRng.Text <> ""

I think maybe this was to correct a bug in the beta but I'm not sure.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top