如何只针对PPT某几页的进行文本替换
比如一个10页PPT,每页都有相同文本(如 123),请问如何进行替换操作,只将7-10页的相同文本(即 123)替换成其它文本(如 456),而1-6页中的文本不进行替换操作(保持 123)?谢谢各位了 在7-10页中遍历 谢谢您的回答。请问7-10页遍历是在vba里实现吗?是的话,请问您能够提供核心的代码吗?我PPT的vba不太懂,谢谢您了。 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
页:
[1]