Macro Error Message - How do I fix?

T

Teresa!

I am running a Macro in PPT but I get a message each time I try to run the
Macro that says "Run time error '91' Object Variable or With Block Variable
not set. Here is the code I used:Sub HyperLinkSearchReplace()

Dim oSl As Slide
Dim oHl As Hyperlink
Dim sSearchFor As String
Dim sReplaceWith As String
Dim oSh as Shape

sSearchFor = InputBox("What text should I search for?", "Search for ...")
If sSearchFor = "" Then
Exit Sub
End If

sReplaceWith = InputBox("What text should I replace" & vbCrLf _
& sSearchFor & vbCrLf _
& "with?", "Replace with ...")
If sReplaceWith = "" Then
Exit Sub
End If

For Each oSl In ActivePresentation.Slides

For Each oHl In oSl.Hyperlinks
oHl.Address = Replace(oHl.Address, sSearchFor, sReplaceWith)
oHl.SubAddress = Replace(oHl.SubAddress, sSearchFor, sReplaceWith)
Next ' hyperlink

' and thanks to an astute user on the PPT Newsgroup, lets fix OLE
links too
For Each oS In oSl.Shapes
If oSh.Type = msoLinkedOLEObject Then
oS.LinkFormat.SourceFullName = _
Replace(oShape.LinkFormat.SourceFullName, _
sSearchFor, sReplaceWith)
End If
Next

Next ' slide

End Sub


Any help would be greatly appreciated.
 
D

David M. Marcovitz

Your missing an h on this line:

For Each oS In oSl.Shapes

It should be For Each oSh ...

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
T

Teresa!

Thank you, David. I made the change and now it's telling me "Object
Required". what does that mean and how can I fix it?
 
D

David M. Marcovitz

Two lines down, another oS should be oSh.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
D

David M. Marcovitz

One more thing. When you get a runtime error, hit the Debug button and it
should highlight the line that is causing the error. This should help you
track down any problems.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
T

Teresa!

David, Sorry about the thread thing. I am new to this and wasn't sure if you
would see my reply. I did fix the "h" problem in both places in the code but
am now getting a new error message where it says "Run time error '424' Object
required" and it highlights this portion of the code:

oSh.LinkFormat.SourceFullName = _
Replace(oShape.LinkFormat.SourceFullName, _
sSearchFor, sReplaceWith)

Thanks again for all your help!
 
D

David M. Marcovitz

This time instead of oS, you have used oShape. But the error is the same.
It should be oSh.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
T

Teresa!

It Works! You're a genius, David! You've saved me a lot of valuable time. I
really appreciate it!

-Teresa
 
D

David M. Marcovitz

Glad I could help. Wait until you have some really difficult questions
before you start calling me a genius.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
T

Teresa!

OK, here's a really hard question (maybe) how can I link the title of each
slide to update with the excel document. For example, let's say my title is
Project Falcon and this title appears in the excel sheet. Is there a way to
link the title of each slide with the title in excel? let's say slide 1 would
read "Project Falcon - Company Overview" Can we rig it to just update the
"Project Falcon" portion?
 

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