J
Jeff Jones
I'm having an opportuniy meeting an objective. I have a character
string that I need to replace in many presesnations. I, frankly,
don't want to do this manually. It would be easy if PowerPoint
actually allowed me to record the key strokes to do a "replace all"
but it doesn't. I've created the following subroutine. The problem
is complicated by the fact that the text is on the Slidemaster. The
code below selects the first slide. The code doesn't get a hit on the
search string because it's on the slidemaster.
I can activate the slidemaster by including ActiveWindow.ViewType =
ppViewTitleMaster but haven't been able to figure out how to set the
oSld variable to the master. I get a type mismatch. Can anyone help
me to set the slide variable so I can spin through the shapes until
I've gotten to the one with the text I want to change. Any
alternative would do. Once I get this code working I can wrap in the
code to process all the slides in a selected folder.
Sub Change_Text()
Dim oSld As Slide
Dim oShp As Shape
Dim oTxtRng As TextRange
Dim oTmpRng As TextRange
Set oSld = Application.ActivePresentation.Slides(1)
On Error Resume Next
For Each oShp In oSld.Shapes
Set oTxtRng = oShp.TextFrame.TextRange
Set oTmpRng = oTxtRng.Replace(FindWhat:="original text.", _
Replacewhat:="replacement text", WholeWords:=True)
Do While Not oTmpRng Is Nothing
Set oTxtRng = oTxtRng.Characters(oTmpRng.Start +
oTmpRng.Length, _
oTxtRng.Length)
Set oTmpRng = oTxtRng.Replace(FindWhat:="original text", _
Replacewhat:="replacement text", WholeWords:=True)
Loop
Next oShp
End Sub
I'd sure appreciate any suggestions that anyone may have.
Thank you,
Jeff
string that I need to replace in many presesnations. I, frankly,
don't want to do this manually. It would be easy if PowerPoint
actually allowed me to record the key strokes to do a "replace all"
but it doesn't. I've created the following subroutine. The problem
is complicated by the fact that the text is on the Slidemaster. The
code below selects the first slide. The code doesn't get a hit on the
search string because it's on the slidemaster.
I can activate the slidemaster by including ActiveWindow.ViewType =
ppViewTitleMaster but haven't been able to figure out how to set the
oSld variable to the master. I get a type mismatch. Can anyone help
me to set the slide variable so I can spin through the shapes until
I've gotten to the one with the text I want to change. Any
alternative would do. Once I get this code working I can wrap in the
code to process all the slides in a selected folder.
Sub Change_Text()
Dim oSld As Slide
Dim oShp As Shape
Dim oTxtRng As TextRange
Dim oTmpRng As TextRange
Set oSld = Application.ActivePresentation.Slides(1)
On Error Resume Next
For Each oShp In oSld.Shapes
Set oTxtRng = oShp.TextFrame.TextRange
Set oTmpRng = oTxtRng.Replace(FindWhat:="original text.", _
Replacewhat:="replacement text", WholeWords:=True)
Do While Not oTmpRng Is Nothing
Set oTxtRng = oTxtRng.Characters(oTmpRng.Start +
oTmpRng.Length, _
oTxtRng.Length)
Set oTmpRng = oTxtRng.Replace(FindWhat:="original text", _
Replacewhat:="replacement text", WholeWords:=True)
Loop
Next oShp
End Sub
I'd sure appreciate any suggestions that anyone may have.
Thank you,
Jeff