|
Sub pptReplaceText()
Dim oSld As Slide
Dim oShp As Shape
Dim oTxtRng As TextRange
Dim oTmpRng As TextRange
For i = 7 To 10 '7-10页,
'For i=1 To Application.ActivePresentation.Slides.Count '每一页
'或:For Each oSld In Application.ActivePresentation.Slides '每一页(此时省下一行)
Set oSld = Application.ActivePresentation.Slides(i) '
For Each oShp In oSld.Shapes
If oShp.HasTextFrame Then
If oShp.TextFrame.HasText Then
Set oTxtRng = oShp.TextFrame.TextRange
Set oTmpRng = oTxtRng.Replace(FindWhat:="123", Replacewhat:="456", WholeWords:=True)
Do While Not oTmpRng Is Nothing
Set oTxtRng = oTxtRng.Characters(oTmpRng.Start + oTmpRng.Length, oTxtRng.Length)
Set oTmpRng = oTxtRng.Replace(FindWhat:="123", Replacewhat:="456", WholeWords:=True)
Loop
End If
End If
Next oShp
Next
End Sub |
|