Supercharge your PowerPoint productivity with
Supercharge your PPT Productivity with PPTools - Click here to learn more.

Proud member of

PPTools

Image Export converts PowerPoint slides to high-quality images.

PPT2HTML exports HTML even from PowerPoint 2010 and 2013, gives you full control of PowerPoint HTML output, helps meet Section 508 accessibility requirements

Merge Excel data into PowerPoint presentations to create certificates, awards presentations, personalized presentations and more

Resize your presentations quickly and without distortion

Language Selector switches the text in your presentation from one language to another

FixLinks prevents broken links when you distribute PowerPoint presentations

Shape Styles brings styles to PowerPoint. Apply complex formatting with a single click.

Batch Search and Replace for Hyperlinks, OLE links, movie links and sound links

Problem

You 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.

Or you've moved your Excel files from one directory to another and now the links don't work.

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:

Solution

This macro will ask you what text you want to search for and what you want to replace it with.
That it will look at each hyperlink in your presentation and do the search/replace on both the hyperlink Address and Subaddress.

If you're not familiar with hyperlink Address and SubAddress, have a look here:
Hyperlink .SubAddress - How to interpret it

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

And another trick ...

At least some versions of PowerPoint permit you to link to files on the internet. It's more convenient to create the links from files on your local PC, though. So you create the links locally, upload the linked files to the web server, then use the macro above to replace the local file path with the server path.

For example, suppose you have links to
C:\MyFiles\Spreadsheets\TEST.XLSX!Sheet1!R1C1:R5C5

You copy TEXT.XLSX to

http://www.yourdomain.xyz/myfiles/spreadsheets/

Now you can update the links by running the code above and asking it to replace:

C:\MyFiles\Spreadsheets\

with

http://www.yourdomain.xyz/myfiles/spreadsheets/

Your link now points to:

http://www.yourdomain.xyz/myfiles/spreadsheets/TEST.XLSX!Sheet1!R1C1:R5C5

And updates when you open your PPT file.

Limitations

See How do I use VBA code in PowerPoint? to learn how to use this example code.


Did this solve your problem? If so, please consider supporting the PPT FAQ with a small PayPal donation.
Page copy protected against web site content infringement by Copyscape Contents © 1995 - 2022 Stephen Rindsberg, Rindsberg Photography, Inc. and members of the MS PowerPoint MVP team. You may link to this page but any form of unauthorized reproduction of this page's contents is expressly forbidden.

Supercharge your PPT Productivity with PPTools

content authoring & site maintenance by
Friday, the automatic faq maker (logo)
Friday - The Automatic FAQ Maker

Batch Search and Replace for Hyperlinks, OLE links, movie links and sound links
http://www.pptfaq.com/FAQ00773_Batch_Search_and_Replace_for_Hyperlinks-_OLE_links-_movie_links_and_sound_links.htm
Last update 07 June, 2011
Created: