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.

Search & Replace to change OLE link paths

Problem

Suppose you've got a lot of links in a PPT file or files and all the links point to a network share.

Then somebody comes along and installs a new server with a new name. Maybe they copy all of your files to the new server, but all of your links break because they point to \\OldServer\YourPath\ but the files are now on \\NewServer\YourPath\

Solution

This little macro will look for all of the OLE links in your presentation and change \\OldServer\ to \\NewServer\ (and if the folder names changed, it'll fix that too).

You'll need to edit the paths it searches for and replaces where indicated below.

Please run this only on a COPY of your important presentation files. Note that you won't see any changes until you save the presentation then re-open it and allow PowerPoint to update the links. We could force it to update immediately but that'd slow it down considerably.

Sub ChangeOLELinks()
' Note: this will only work in PPT 2000 and later

    Dim oSld As Slide
    Dim oSh As Shape
    Dim sOldPath As String
    Dim sNewPath As String

    ' EDIT THIS TO REFLECT THE PATHS YOU WANT TO CHANGE
    ' Include just the portion of the path you want to change
    ' For example, to change links to reflect that files have moved from
    ' \\boss\p-drive\temp\*.* to
    ' \\boss\Q-drive\temp\*.*
    sOldPath = "\\boss\p-drive\"
    sNewPath = "\\boss\q-drive\"

    On Error GoTo ErrorHandler

    For Each oSld In ActivePresentation.Slides
        For Each oSh In oSld.Shapes
            ' Change only linked OLE objects
            If oSh.Type = msoLinkedOLEObject Then
                On Error Resume Next
                ' Verify that file exists
                If Len(Dir$(Replace(oSh.LinkFormat.SourceFullName, sOldPath, sNewPath))) > 0 Then
                     oSh.LinkFormat.SourceFullName = Replace(oSh.LinkFormat.SourceFullName, sOldPath, sNewPath)
                Else
                      MsgBox("File is missing; cannot relink to a file that isn't present")
                End If
                On Error GoTo ErrorHandler
             End If
        Next    ' shape
    Next    ' slide

    MsgBox("Done!")

NormalExit:
    Exit Sub
ErrorHandler:
    MsgBox("Error " & err.number & vbcrlf & err.description)
    Resume NormalExit

End Sub

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

Search & Replace to change OLE link paths
http://www.pptfaq.com/FAQ00759_Search_-_Replace_to_change_OLE_link_paths.htm
Last update 07 June, 2011
Created: