G
Geoff Cox
Hello,
the following code replaces the word "fred" by "jim" in all slides and
works fine in most cases but appears to fail when there is a table?
How could I keep the tables and still have the macro run?
Thanks
Geoff
Dim oSld As Slide
Dim oShp As Shape
Dim oTxtRng As TextRange
Dim oTmpRng As TextRange
Dim slide_number As Integer
For slide_number = 1 To ActivePresentation.Slides.Count
Set oSld = Application.ActivePresentation.Slides(slide_number)
For Each oShp In oSld.Shapes
Set oTxtRng = oShp.TextFrame.TextRange
Set oTmpRng = oTxtRng.Replace(FindWhat:="fred", _
Replacewhat:="jim", WholeWords:=True)
Do While Not oTmpRng Is Nothing
Set oTxtRng = oTxtRng.Characters(oTmpRng.Start +
oTmpRng.Length, _
oTxtRng.Length)
Set oTmpRng = oTxtRng.Replace(FindWhat:="fred", _
Replacewhat:="jim", WholeWords:=True)
Loop
Next oShp
Next slide_number
the following code replaces the word "fred" by "jim" in all slides and
works fine in most cases but appears to fail when there is a table?
How could I keep the tables and still have the macro run?
Thanks
Geoff
Dim oSld As Slide
Dim oShp As Shape
Dim oTxtRng As TextRange
Dim oTmpRng As TextRange
Dim slide_number As Integer
For slide_number = 1 To ActivePresentation.Slides.Count
Set oSld = Application.ActivePresentation.Slides(slide_number)
For Each oShp In oSld.Shapes
Set oTxtRng = oShp.TextFrame.TextRange
Set oTmpRng = oTxtRng.Replace(FindWhat:="fred", _
Replacewhat:="jim", WholeWords:=True)
Do While Not oTmpRng Is Nothing
Set oTxtRng = oTxtRng.Characters(oTmpRng.Start +
oTmpRng.Length, _
oTxtRng.Length)
Set oTmpRng = oTxtRng.Replace(FindWhat:="fred", _
Replacewhat:="jim", WholeWords:=True)
Loop
Next oShp
Next slide_number