'How to Bulk Change Source Links?

Trying to change the Excel source file for charts and objects linked in a PowerPoint deck.

I found this:

Sub ChangeOLELinks()

    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
    sOldPath = InputBox("Enter Old Project ie: \Development\", "Old Path") 
    sNewPath = InputBox("Enter New Project ie: \Test\", "New Path") 
     
    On Error GoTo ErrorHandler

    For Each oSld In ActivePresentation.Slides
        For Each oSh In oSld.Shapes
            If oSh.Type = msoLinkedOLEObject Then
            
                Dim stringPath   As String
                stringPath = Replace(oSh.LinkFormat.SourceFullName, sOldPath, sNewPath, 1, , vbTextCompare)
               
                oSh.LinkFormat.SourceFullName = stringPath
               ' set update mode to auto and update then set it back to manual
                oSh.LinkFormat.AutoUpdate = ppUpdateOptionAutomatic
                oSh.LinkFormat.Update
                oSh.LinkFormat.AutoUpdate = ppUpdateOptionManual
                               
            End If
        Next oSh
    Next oSld
    ActivePresentation.Save

    MsgBox ("Done!")
    
NormalExit:
    Exit Sub
        
ErrorHandler:
    MsgBox ("Error " & Err.Number & vbCrLf & Err.Description)
    Resume NormalExit
    
End Sub

This works for OLE objects/links. It isn't updating any of the linked charts.

How can I include charts?



Solution 1:[1]

As your charts are paste-linked (4th option) from Excel, they're of msoChart type.
The LinkFormat.SourceFullName property works for this type too so you just have to replace your

If oSh.Type = msoLinkedOLEObject

with

if oSh.Type = msoChart

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Draken