Header
PowerPoint tips, hints and tutorials that will change your presentations for ever!

INDEX

 

Jigsaws
Sounds
Video
Custom Shows
vba code
NaviSlides
Games for teachers
Bullets
Triggers
Security
Flash Cards
Multiple Instances
PowerPoint 2007
Mail Merge
Random events
Animation
Hyperlinks
Set spellcheck language


Home buttonTutorial buttonContact buttonProducts button


PowerPoint Search & Replace

This code replaces ALL instances of <find> with the text in Slide 1 /Shape 1 and all instances of <find2> with the text in Shape 2. Easy to adapt for more swaps or text in different shapes / places! Not case sensitive.

Sub changeme(sFindMe As String, sSwapme As String)
Dim osld As Slide
Dim oshp As Shape
Dim otemp As TextRange
Dim otext As TextRange
Dim Inewstart As Integer

For Each osld In ActivePresentation.Slides
For Each oshp In osld.Shapes
If oshp.HasTextFrame Then
If oshp.TextFrame.HasText Then

Set otext = oshp.TextFrame.TextRange
Set otemp = otext.Replace(sFindMe, sSwapme, , msoFalse, msoFalse)
Do While Not otemp Is Nothing
Inewstart = otemp.Start + otemp.Length
Set otemp = otext.Replace(sFindMe, sSwapme, Inewstart, msoFalse, msoFalse)
Loop

End If
End If

Next oshp
Next osld
End Sub

Sub swap()
Dim sFindMe As String
Dim sSwapme As String
sFindMe = "<find>"
'change this to suit
sSwapme = ActivePresentation.Slides(1).Shapes(1).TextFrame.TextRange
Call changeme(sFindMe, sSwapme)
sFindMe = "<find2>"
sSwapme = ActivePresentation.Slides(1).Shapes(2).TextFrame.TextRange
Call changeme(sFindMe, sSwapme)
End Sub

Run the code "swap"

Don't know how to use the code?

 

 

 

 
 

Back to the Index Page

POWERPOINT BLOG

Articles on your favourite sport

Free Microsoft PowerPoint Advice, help and tutorials, Template Links
This website is sponsored by Technology Trish Ltd
© Technology Trish 2007
Registered in England and Wales No.5780175
PowerPoint® is a registered trademark of the Microsoft Corporation