Supercharge your PowerPoint productivity with
|
PPTools |
ProblemYou have a presentation that includes an extensive collection of hyperlinks to various external files. Then a server name or mapped drive letter changes and all of your links break. You know that all you need to do is change, say, the "P:\" in each link to the new drive name "Q:\" and a simple Search and Replace would do the job. Unfortunately, PowerPoint's Search and Replace feature doesn't work with hyperlink text, so you're stuck doing all of the replacements one at a time by hand. Or ... you could try this: SolutionThis macro will ask you what text you want to search for and what you want to replace it with. If you're not familiar with hyperlink Address and SubAddress, have a look here: And to get a look at the hyperlinks in the presentation before you start to search and replace, see Show Me: The hyperlinks in my presentation or use the Links Report feature of the free PPTools FixLinks demo. Here's the code:
Option Explicit
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
On Error Resume Next
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 several astute user suggestions, let's fix OLE links
' and movie/sound linkes too
For Each oSh In oSl.Shapes
If oSh.Type = msoLinkedOLEObject _
Or oSh.Type = msoMedia Then
oSh.LinkFormat.SourceFullName = _
Replace(oSh.LinkFormat.SourceFullName, _
sSearchFor, sReplaceWith)
End If
Next
Next ' slide
End Sub
Limitations
See How do I use VBA code in PowerPoint? to learn how to use this example code. Español Deutsch Français Português Italiano Nederlands Greek Japanese Korean Chinese |
Supercharge your PPT Productivity with PPTools
|
content authoring & site maintenance by |
Search and Replace for Hyperlinks
http://www.pptfaq.com/FAQ00773.htm
Last update 10 December, 2008