Changing Source Links in a PPT

Eldrod

Board Regular
Joined
Mar 11, 2010
Messages
76
I'm hoping someone already has the VBA code for this. I have a linked set of files, one Excel and one PPT with the charts in the PPT dynamically linked to the Excel file. I need to use this set sort of like a template so that I can make copies of both of these under new names and change the embedded Excel charts in the PPT to point to the new Excel copy. This way each new PPT will only be updated by the new linked Excel file, and not the original version.
I found this code to create a module under VBA, but it does not seem to work and my PowerPoint VBA skills are lacking. I do like the way it pops up the file selection box so that the new Excel file can be easily selected. Also, I'm running this on the Mac:Excel 2011 version if that matters.
Code:
Sub UpdateLinks() 
    Dim ExcelFile 
    Dim exl As Object 
    Set exl = CreateObject("Excel.Application") 
     
     'Open a dialog box to promt for the new source file.
    ExcelFile = exl.Application.GetOpenFilename(, , "Select Excel File") 
     
    Dim i As Integer 
    Dim k As Integer 
     
     'Go through every slide
    For i = 1 To ActivePresentation.Slides.Count 
        With ActivePresentation.Slides(i) 
             'Go through every shape on every slide
            For k = 1 To .Shapes.Count 
                'Turn of error checking s that it doesn 't crash if the current shape doesn't already have a link
                On Error Resume Next 
                 'Set the source to be the same as teh file chosen in the opening dialog box
                .Shapes(k).LinkFormat.SourceFullName = ExcelFile 
                If .Shapes(k).LinkFormat.SourceFullName = ExcelFile Then 
                     'If the change was successful then also set it to update automatically
                    .Shapes(k).LinkFormat.AutoUpdate = ppUpdateOptionAutomatic 'other option is ppUpdateOptionManual
                End If 
                On Error Goto 0 
            Next k 
        End With 
    Next i 
     
End Sub
Any help in figuring this out would be greatly appreciated!
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi Elrod,

Just saw your original post and was wondering if you ever figured it out? Am currently stuck in exactly the same predicament...

Thanks!
 
Upvote 0

Forum statistics

Threads
1,216,124
Messages
6,128,991
Members
449,480
Latest member
yesitisasport

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top