G
Guest
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.
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.