Find and Replace Text in Powerpoint from Excel

lt0218

New Member
Joined
May 10, 2011
Messages
1
I am completely lost trying to write this macro. I am trying to use the Powerpoint.Application object to access an existing presentation and search through all slides for text "xxxx" and replace with text from a cell in excel. I am able to do this using excel and word but am completely stumped when it comes to excel and powerpoint. I see a lot of examples out there of a macro within powerpoint, but I can't seem to find any help regarding accomplishing it through excel. The general gist of it should be to search through all slides, all shapes within each slide for text ranges that contain the string "xxxx"


Thanks in advance!
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
I successfully used this code with just powerpoint, but when I move it inside my excel module. I get error 429 active x componenet cant create object at the red line. Do I have to reestablish what the Active presentation is?
Thanks?

Code:
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

[COLOR="Red"]For Each osld In ActivePresentation.Slides[/COLOR]
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 = "Word To Find"
'change this to suit
sSwapme = ActivePresentation.Slides(1).Shapes(1).TextFrame.TextRange
Call changeme(sFindMe, sSwapme)

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,254
Members
452,900
Latest member
LisaGo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top