Replace Text in Only One Slide?

N

nillaster

Dear All,

I know that PowerPoint lets you find and replace a text string one
occurrence at a time. There is also a "replace all" function that will
replace all occurrences of a text string. However, is it possible to
replace all occurrences on one slide only? This would speed up my work
considerably.

Thank you,

Jacob
 
J

John Wilson

You can with vba

Sub ReplaceText()

Dim strchange As String
Dim strto As String
Dim fromslide As Integer
Dim toslide As Integer
Dim n As Integer
Dim oSld As Slide
Dim oShp As Shape
Dim oTxtRng As TextRange
Dim oTmpRng As TextRange


strchange = InputBox("change")
strto = InputBox("to")
fromslide = InputBox("From slide")
toslide = InputBox("To slide")

For n = fromslide To toslide
Set oSld = Application.ActivePresentation.Slides(n)

For Each oShp In oSld.Shapes
Set oTxtRng = oShp.TextFrame.TextRange
Set oTmpRng = oTxtRng.Replace(FindWhat:=strchange, _
Replacewhat:=strto, WholeWords:=True)
Do While Not oTmpRng Is Nothing
Set oTxtRng = oTxtRng.Characters(oTmpRng.Start + oTmpRng.Length, _
oTxtRng.Length)
Set oTmpRng = oTxtRng.Replace(FindWhat:=strchange, _
Replacewhat:=strto, WholeWords:=True)
Loop
Next oShp
Next n
End Sub
--
If you dont know how to use vba see here:http://www.pptfaq.com/FAQ00033.htm

Did that answer the question / help?
_____________________________
John Wilson
Microsoft Certified Office Specialist
http://www.technologytrish.co.uk/ppttipshome.html
 

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