Edit links in PowerPoint using VBA

In a previous post, we considered how to link Excel files to PowerPoint presentations.  This can be a significant time saver as the PowerPoint presentation can be updated automatically.  Once you have created the links, life is brilliant, until . . . you need to change which file the PowerPoint presentation is linked to.  You could use the “edit links” option.  But there is one big issue with PowerPoint, you have to edit the links one by one.  If you have 100 links to different Excel workbooks you have to update each of them.  If you have 100 links to the same Excel workbook you would expect to be able to update them all at the same time.  But that’s just not how it works unfortunately, you still have to update each link individually.

Have no fear – VBA to the rescue.  Below you will find VBA code for PowerPoint and for Excel.  Yes, that’s right, you can update the links to a PowerPoint document from within Excel.  Pretty cool eh?

Here are a few notes for using the code:

  • The Excel code has been written using Early Binding.  Don’t worry if you don’t know what that means.  In the Excel Visual Basic Editor select Tools -> References -> Microsoft PowerPoint x.xx Object Library.  This will ensure that can Excel and speak PowerPoint.
  • When changing file paths remember to end the file path with a slash “\”

Edit the linked documents using PowerPoint VBA

Open the Visual Basic Editor in PowerPoint (ALT+F11).

Right-click on the VBAProject, select Insert -> Module.

PowerPoint VBA insert Module

Copy the code below into the code window.

PowerPoint VBA copy code

Sub EditPowerPointLinks()

Dim oldFilePath As String
Dim newFilePath As String
Dim pptPresentation As Presentation
Dim pptSlide As Slide
Dim pptShape As Shape

'The old file path as a string (the text to be replaced)
oldFilePath = "String of\File Path\To Be Replaced\Excel File.xlsx"

'The new file path as a string (the text to replace with)
newFilePath = "String of\New File Path\Excel File 2.xlsx"

'Set the variable to the PowerPoint Presentation
Set pptPresentation = ActivePresentation

'Loop through each slide in the presentation
For Each pptSlide In pptPresentation.Slides

    'Loop through each shape in each slide
    For Each pptShape In pptSlide.Shapes
   
        'Find out if the shape is a linked object or a linked picture
        If pptShape.Type = msoLinkedPicture Or pptShape.Type _ 
        = msoLinkedOLEObject Or pptShape.Type = msoLinkedChart Then

            'Use Replace to change the oldFilePath to the newFilePath
            pptShape.LinkFormat.SourceFullName = Replace(LCase _
            (pptShape.LinkFormat.SourceFullName), LCase(oldFilePath), newFilePath)
            
        End If
    Next
Next

'Update the links
pptPresentation.UpdateLinks


End Sub

You just need to set the values for the newFilePath and oldFilePath variables listed in the code above.

Edit the linked documents from Excel using VBA

It is also possible to update the links in PowerPoint from within Excel.

Press ALT + F11 to open the Excel Visual Basic Editor.  Click Insert -> Module. Copy the code below into the new Module.

The code below uses Early Binding, so you will need to set the references to the PowerPoint object library.  Select Tools -> References, then select the Microsoft PowerPoint x.xx Object Library from the list.

Sub EditPowerPointLinks()

'Set the link to the Object Library: 
'Tools -> References -> Microsoft PowerPoint x.xx Object Library

Dim oldFilePath As String
Dim newFilePath As String
Dim sourceFileName As String
Dim pptApp As PowerPoint.Application
Dim pptPresentation As Object
Dim pptSlide As Object
Dim pptShape As Object

'The file name and path of the file to update
sourceFileName = "C:\File Path\Of Source File\File Name.pptx"

'The old file path as a string (the text to be replaced)
oldFilePath = "String of\File Path\To Be Replaced\Excel File.xlsx"

'The new file path as a string (the text to replace with)
newFilePath = "String of\New File Path\Excel File2.xlsx"

'Set the variable to the PowerPoint Application
Set pptApp = New PowerPoint.Application

'Make the PowerPoint application visible
pptApp.Visible = True

'Set the variable to the PowerPoint Presentation
Set pptPresentation = pptApp.Presentations.Open(sourceFileName)

'Loop through each slide in the presentation
For Each pptSlide In pptPresentation.Slides

    'Loop through each shape in each slide
    For Each pptShape In pptSlide.Shapes
   
        'Find out if the shape is a linked object or a linked picture
        If pptShape.Type = msoLinkedPicture Or pptShape.Type _
        = msoLinkedOLEObject Or pptShape.Type = msoLinkedChart Then

            'Use Replace to change the oldFilePath to the newFilePath
            pptShape.LinkFormat.SourceFullName = Replace(LCase _
            (pptShape.LinkFormat.SourceFullName), LCase(oldFilePath), newFilePath)

        End If
    Next
Next

pptPresentation.UpdateLinks

'Save, close and quit the application
pptPresentation.Save
pptPresentation.Close
pptApp.Quit


'Release the memory
Set pptApp = Nothing
Set pptPresentation = Nothing
Set pptSlide = Nothing
Set pptShape = Nothing

End Sub

For the code above it will be necessary to set the values for the sourceFileName, oldFilePath and newFilePath variables.


Discover how you can automate your work with our Excel courses and tools.

Excel Academy

Excel Academy
The complete program for saving time by automating Excel.

Excel Automation Secrets

Excel Automation Secrets
Discover the 7-step framework for automating Excel.

Office Scripts Course

Office Scripts: Automate Excel Everywhere
Start using Office Scripts and Power Automate to automate Excel in new ways.

65 thoughts on “Edit links in PowerPoint using VBA”

  1. I am trying to get this to work using Office 16. I am not sure what I am missing but I have tried both the excel method and the ppt method.
    Any suggestions?

    I have 12 spreadsheets with about 30 links each to the same spreadsheet.

    Thank you so much for an insight you can provide.

    ‘The file name and path of the file to update
    sourceFileName = “\\mikewin10\C$\Users\mdavis\Desktop\Budgets\Sales Meeting 2019\A-Jan 2019.pptm\”

    ‘The old file path as a string (the text to be replaced)
    oldFilePath = “\\mikewin10\C$\Users\mdavis\Desktop\Budgets\Sales Meeting 2018\2018 Source.xlsx\”

    ‘The new file path as a string (the text to replace with)
    newFilePath = “\\mikewin10\C$\Users\mdavis\Desktop\Budgets\Sales Meeting 2019\2019 Source.xlsx\”

    Reply
    • Hi Stacey,

      Thanks for your question.

      My guess is that you need to remove the \ from the end of the file path. Let me know if that works.

      Reply
      • Hi, i’m in the same difficulty with Powerpoint 2016.

        With or Without the \ from the end of the file path, the path is not update.

        Do you have an other idea ? Thanks for your help !

        Sub EditPowerPointLinks()

        Dim oldFilePath As String
        Dim newFilePath As String
        Dim pptPresentation As Presentation
        Dim pptSlide As Slide
        Dim pptShape As Shape

        ‘The old file path as a string (the text to be replaced)
        oldFilePath = “C:\Users\dbi\Downloads\Automatiser_Excel\Analyse_Satisfaction_Kyowa.xlsx\”

        ‘The new file path as a string (the text to replace with)
        newFilePath = “C:\Users\dbi\Downloads\Automatiser_Excel\TEST\Analyse_Satisfaction_Kyowa2.xlsx\”

        ‘Set the variable to the PowerPoint Presentation
        Set pptPresentation = ActivePresentation

        ‘Loop through each slide in the presentation
        For Each pptSlide In pptPresentation.Slides

        ‘Loop through each shape in each slide
        For Each pptShape In pptSlide.Shapes

        ‘Find out if the shape is a linked object or a linked picture
        If pptShape.Type = msoLinkedPicture Or pptShape.Type _
        = msoLinkedOLEObject Then

        ‘Use Replace to change the oldFilePath to the newFilePath
        pptShape.LinkFormat.SourceFullName = Replace(LCase _
        (pptShape.LinkFormat.SourceFullName), LCase(oldFilePath), newFilePath)

        End If
        Next
        Next

        ‘Update the links
        pptPresentation.UpdateLinks

        End Sub

        Reply
  2. Hi Mark, just wanted to tell you that the info you wrote here is priceless! Last week I had to deal with a project wherein a pair of files inter-connected (Excel feeding PowerPoint through linked ranges across 50+ slides) kept changing locations together as a pair. The problem how to keep this pair connected at all times despite path changes as well as the Excel file renaming. The solution was to update all the links of the PowerPoint presentation from within Excel and the technique in my macro was based on the code you introduced. Saved me a lot of time writing it myself from scratch. Brilliant piece of work. Thank you for sharing.

    One comment – The variable pptApp is also an abject and at the end of the code you ought to set it to Nothing together with all the other object variables.

    Reply
  3. Hi Mark, I can’t get either the powerpoint macro or the excel macro to run correctly. In both cases I can see the macro running, but no changes take place to the ppt. For example when I run the macro in Excel, I see it open the Powerpoint file, it spins for a while, then closes the Powerpoint. But when I re-open the Powerpoint it’s the exact same as it was. Any thoughts? Thanks!

    Reply
    • Hi Allen – I’m guessing that the issues are likely to be either:

      (1) the text string set for the oldFilePath is not the same as the text string in the PowerPoint file.

      (2) the after making the change, the newFilePath is not a valid file. PowerPoint will only update if the path is valid and exists.

      Reply
  4. Hi, Thank you for this ! I am totally new to VBA so perhaps a stupid question but does it also work if a Powerpoint presentation is linked to 3 different excel files ? How should i adapt the code ? thx !! u

    Reply
    • The code works based on a Find & Replace of the file path and file name. So it depends specifically on the find text string you’re using as to whether it will match multiple linked files.

      Reply
  5. Hi. I cant make it work. there is always an error
    LinkFormat.SourceFullName : Failed

    sourceFileName = “D:\200 OpRev\OpRevTool\Data Traffic Forecast\Technology OpRev-NSP-Template4.pptx”

    ‘The old file path as a string (the text to be replaced)
    oldFilePath = “D:\200 OpRev\OpRevTool\Data Traffic Forecast\OpRev Data2.xlsm”

    ‘The new file path as a string (the text to replace with)
    newFilePath = “D:\200 OpRev\OpRevTool\Data Traffic Forecast\OpRev Data3.xlsm”

    ‘Set the variable to the PowerPoint Application
    Set pptApp = New PowerPoint.Application

    ‘Make the PowerPoint application visible
    pptApp.Visible = True

    ‘Set the variable to the PowerPoint Presentation
    Set pptPresentation = pptApp.Presentations.Open(sourceFileName)

    ‘Loop through each slide in the presentation
    For Each pptSlide In pptPresentation.Slides

    ‘Loop through each shape in each slide
    For Each pptShape In pptSlide.Shapes

    ‘Find out if the shape is a linked object or a linked picture
    If pptShape.Type = msoLinkedPicture Or pptShape.Type _
    = msoLinkedOLEObject Then

    ‘Use Replace to change the oldFilePath to the newFilePath
    pptShape.LinkFormat.SourceFullName = Replace(LCase _
    (pptShape.LinkFormat.SourceFullName), LCase(oldFilePath), newFilePath)

    End If
    Next

    its stopping on the LinkFormat.SourceFullName

    Kindly advise 🙁 Thanks in advance

    Reply
    • Hi Don

      Work through the example in this post. Set up some fake data and follow all the steps. It explains what you need to do.

      If it doesn’t work, then it may be because you’re not using Excel.

      Reply
  6. Hi! Hope you can help me.
    I dont know anything about macros, so I tried to run it and it says (PowerPoint.Application ) User-defined type not defined.

    What could it be?

    Thanks in advance.

    Reply
    • Hi Angeles – It’s probably because you have not referenced the PowerPoint Object Library. This is essential when using the Early Binding method – the instructions for this are included at the top of the post.

      Reply
  7. Thank you for the post! Looking at the excel VBA version, would it be possible to adapt it where you could have the sourceFileName, oldFilePath and newFilePath variables to source from cells within the excel spreadsheet. For example:

         sourceFileName = Range("E5").Value
         oldFilePath = Range("C5").Value
         newFilePath = Range("B5").Value
    

    and have a macro such as:

        Application.CutCopyMode = False
        Range("B5").Select
        Selection.Copy
        Range("C5").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Range("A5").Select
        Application.CutCopyMode = False
        Selection.Copy
        Range("B5").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Range("D5").Select
        Selection.Copy
        Range("E5").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
    

    (This would update the last file location to cell C5, update the new location to B5, and update the current PPT location in E5.)

    Using those adjustments to your macro, I am receiving the following error:
    *Run-time error ‘-2147467259 (80004005)’:
    Method ‘SourceFullName’ of object ‘LinkFormat’ failed*

    and it is highlighting the following as the portion of code:

    pptShape.LinkFormat.SourceFullName = Replace(LCase _
                (pptShape.LinkFormat.SourceFullName), LCase(oldFilePath), newFilePath)
    

    Any suggestions on where I’m going wrong?

    Reply
    • The error is appearing in the line of code which changes the file path. The new file must exist, else it will create an error. This is the most likely cause of the error. Use the following to check if the file exists.

      MsgBox Replace(LCase(pptShape.LinkFormat.SourceFullName), LCase(oldFilePath), newFilePath

      Once you’re happy that it works correctly, you can remove that line of code.

      Reply
      • Got it to work! The problem was that when I used the Cell values, it would add an [____]Report around the .xlsx file name. To resolve that, I did a Find/Replace to change it to the link that would work for PPT. Thanks a ton for your assistance, you helped me solve a problem I have been having for the past 3 weeks!

        Reply
  8. I’m looking for a way to list the links rather than edit or change them. I’ve got PowerPoint files with tons of Excel links that are missing the workbooks and I think it would be great if I could generate a list of the workbook names so I might be able to more easily hunt down the workbooks. Even better if the list could include initials of author, date modified and range. Can the above code be modified to do this instead of editing the links?

    Reply
    • Hi Reinaldo – Yes you can modify the code to list the links:

      (1) Create a variable at the start of the macro:

      Dim i as Long

      (2) Change this line of code:

      pptShape.LinkFormat.SourceFullName = Replace(LCase _
      (pptShape.LinkFormat.SourceFullName), LCase(oldFilePath), newFilePath)
      

      To this:

      ActiveSheet.Range("A1").Offset(i, 0) = pptShape.LinkFormat.SourceFullName
      i = i + 1
      

      (3) Remove the following lines:

      pptPresentation.UpdateLinks
      
      pptPresentation.Save
      

      There are a few other lines which are not required now, but they shouldn’t cause you any issues.

      In terms of getting the initials of the author and the date modified. I don’t believe this is stored in the PowerPoint file, so you won’t be able to get this.

      Just for information – you can find a list of all the linked files by clicking File -> Info -> Edit Links to Files (look at the bottom right of the screen).

      Reply
        • I will write a separate post about this, as it appears to be an area that people want to know about, but it’s not really the purpose of this post.

          Reply
      • Get links from slides into excel file

        Sub EditPowerPointLinks()

        ‘Set the link to the Object Library:
        ‘Tools -> References -> Microsoft PowerPoint x.xx Object Library

        Dim oldFilePath As String
        Dim newFilePath As String
        Dim sourceFileName As String
        Dim xlApp As Object
        Dim xlWorkBook As Object
        Dim pptApp As PowerPoint.Application
        Dim pptPresentation As Object
        Dim pptSlide As Object
        Dim pptShape As Object
        Dim i As Long

        ‘you should have an Excel file named “File.xlsx” in the same folder

        Set xlApp = CreateObject(“Excel.Application”)

        xlApp.Visible = True
        Set xlWorkBook = xlApp.Workbooks.Open(ActivePresentation.Path & “\” & “File.xlsx”, True, False)
        Set xlWorkBook = xlApp.ActiveWorkbook

        Presentations(1).Windows(1).Activate

        ‘Set the variable to the PowerPoint Application
        Set pptApp = New PowerPoint.Application

        ‘Make the PowerPoint application visible
        pptApp.Visible = True

        ‘Loop through each slide in the presentation
        For Each pptSlide In Presentations(1).Slides

        ‘Loop through each shape in each slide
        For Each pptShape In pptSlide.Shapes

        ‘Find out if the shape is a linked object or a linked picture
        If pptShape.Type = msoLinkedPicture Or pptShape.Type _
        = msoLinkedOLEObject Or pptShape.Type = msoLinkedChart Then

        xlWorkBook.sheets(1).Range(“A1”).Offset(i, 0) = pptShape.LinkFormat.SourceFullName
        i = i + 1

        End If
        Next
        Next

        ‘Save, close and quit the application
        pptPresentation.Close
        pptApp.Quit

        ‘Release the memory
        Set pptApp = Nothing
        Set pptPresentation = Nothing
        Set pptSlide = Nothing
        Set pptShape = Nothing

        End Sub

        I also have a referece to Excel xx Object Library
        Thanks a lot.

        Reply
  9. I am trying to run the above code but it throws an error as ‘Microsoft excel is waiting for another application to complete an OLE action meaning’
    Any advise on how this can be resolved?

    Reply
    • I would start by trying to find out if it is the macro or another reason causing the problem. Use the task manager closing all office applications, then try the macro again. If it runs OK, then it’s probably something else causing the issue.

      Does it cause a problem for both the PowerPoint and Excel versions of the code?

      Reply
  10. Thanks for the prompt response. What i am trying to achieve is i have a ppt with several charts/ tables linked to an excel that has all the calculation through which charts/ tables are created. i want to automate the process of updating the ppt on a click of a button once user updates data in the excel. Currently user has to manually open the ppt and click on update chart which takes lot of time. Can you help me with this?

    Reply
  11. Hi, Thanks for this helpful post!
    I just ran into some issue because the old pah that I’m looking for does not exist but in the file because it is a path of another PC and my goal is to change it to my path that holds my name.
    so the code of the paths look like this:

    ‘The old file path as a string (the text to be replaced)
    oldFilePath = “C:\Users\Rayan.Alm\Desktop\Master PMO.xlsx”

    ‘The new file path as a string (the text to replace with)
    newFilePath = “C:\Users\Sarah.Alo\Desktop\Master PMO.xlsx”

    As far as I understood, this should change the source in the “edit links to file”
    when I run the macro but it does not work for some reason.
    Any hints why?

    Reply
  12. Hi,
    The following setup works for pictures but it dose not do it for Charts.
    How might i fix it?

    Another thing that might be of importance is that every chart is in a placeholder. Meaning that if you click the selection pane in one of my slides the chart is actually listed as a placeholder, and not an object. Any ideas?

    Sub EditPowerPointLinks()

    Dim oldFilePath As String
    Dim newFilePath As String

    Dim pptPresentation As Object
    Dim pptSlide As Object
    Dim pptShape As Object

    ‘The old file path as a string (the text to be replaced)
    oldFilePath = “\\nosfjfil01\common\Corporate\Group CFO Finance IT\CorpFinance\Group Analysis and Reporting\Preliminary\preliminary_model.xlsm”

    ‘The new file path as a string (the text to replace with)
    newFilePath = “\\nosfjfil01\common\Corporate\Group CFO Finance IT\CorpFinance\Group Analysis and Reporting\Quality support\Liger\Liger_model.xlsm”

    ‘Set the variable to the PowerPoint Presentation
    Set pptPresentation = ActivePresentation

    ‘Loop through each slide in the presentation
    For Each pptSlide In pptPresentation.Slides

    ‘Loop through each shape in each slide
    For Each pptShape In pptSlide.Shapes

    ‘Find out if the shape is a linked object or a linked picture
    If pptShape.Type = msoLinkedPicture Or pptShape.Type = msoLinkedOLEObject Then

    ‘Use Replace to change the oldFilePath to the newFilePath
    pptShape.LinkFormat.SourceFullName = Replace(LCase _
    (pptShape.LinkFormat.SourceFullName), LCase(oldFilePath), newFilePath)

    End If
    Next
    Next

    ‘Update the links
    ‘pptPresentation.updatelinks

    End Sub

    Reply
    • I have a similar issue. The if condition is never true because I dont have those types, but I do have links. If I replace the types in the condition with one I have the conditional code will error because it requires a linked object.

      Is this similar to your issue. If so, how did you resolve this?

      Reply
  13. Thanks for sharing this solution. Works well. However, the more links that I have in my spreadsheet, the slower the macro gets. Up to about 10 minutes per run now. Is there any way to speed this up?

    Reply
    • If you open all the existing linked and to-be linked workbooks before running the macro it will run significantly faster.

      If the linked workbook is closed; it is opened, updated and closed for each individual link. If the workbooks are already open, it doesn’t need to open and close them. This is a quirk with Excel, rather than the macro itself.

      Reply
  14. Off the Grid, a million thank yous for this! Your comment to Evan in mid-January was instrumental in getting my macro working — even a reduced-size file for me still has 44 links in it and takes about an hour to run, with all the files open in the background. That said, leagues better than doing this all by hand!!!

    Reply
  15. HI
    How can I use this macro to change links when both ppt and xlsx are saved on sharepoint. In such case my “path string gives error

    Reply
    • Not for me. I realized the condition is never true and that of the types listed I only have charts. Using msoChart the condition was true, but the conditional code would not run. The error says that code requires a linked object.

      Riddle:
      I have links at file > info > edit links to files, but not linked objects? What do I have? 🙂

      Reply
  16. Hi,

    Will this code work even if I have Read-only access to the linked file paths?

    Purpose: I have approx 300 links in a PPT linked to a read-only excel file and I want to change the source of all the links to another excel file for which I have both read & write access.

    Would be great if I can get some help on this 🙂

    Regards,
    Madhu

    Reply
  17. I have tried this so many different iterations.
    I have 200 Linked Chart and Text that I copied into a PowerPoint 2019 presentation.
    My Charts and Excel File is in:
    C:\Users\mikea\Documents\1-MyDocuments\1-Annetta\OT\SURVEYS\2019 Survey #2 SYMPTOMS & DIAGNOSES\NEW FILTERED CHARTS AND DATA LINKED SURVEY #2 ANALYSIS.XLSM”

    My PowerPoint presentation is also in that folder.
    I would like to move the Link in PowerPoint to a Flash Drive, such as a : “H:\Data\NEW FILTERED CHARTS AND DATA LINKED SURVEY #2 ANALYSIS.XLSM.xlsx” Can this be done? Can you repost the solution again?

    Reply
  18. Hi Mark, thanks for your post this vba is amazing! Ive slightly adjusted it so the user inputs for source/old and new file paths look at excel cells for ease of use ie;

    sourceFileName = Range(“B1”).Value.
    oldFilePath = Range(“B2”).Value
    newFilePath = Range(“B3”).Value

    One question, i’d like to loop this macro but with a different set of file path and source links so it can update multiple PowerPoints at once (I’ve got 25 of them). Any pointers for a vba amateur? Thanks!

    Reply
    • There are a few ways you could do it. My best advice is to get stuck in and keep trying until you solve it. You’ll learn a lot in the process.

      Reply
  19. Thanks for the macro. Works like a charm, except that it popped up hundreds of dialog boxes requiring me to click Don’t Update. (For now, I’m just rolling the files and updating the source for the links. I’ll update the links later, after the source file has been fully updated.)

    Is there a way to adjust the code so that I don’t have to interact with it so much? Can it just update the source file for each link without asking me whether I want to update or not?

    Reply
    • I suspect the issue is that you have linked elements in your Excel workbooks. You will need to change your Excel workbooks to manual update first, then the update won’t be triggered went the file is opened by PowerPoint.

      Another approach is to open all the Excel files first. This speeds up the entire process to complete in seconds, instead of minutes.

      Reply
  20. Many thanks for this macro!

    I have a qery, Is there a way to adapt this macro so that it captures any new changes amongst the excel charts. For example, if i’ve changed the colour of a particular line or added a new time period, the macro above updates data but doesn’t seem to reflect these changes when updating the charts across the powerpoint.

    Reply
    • It depends on how you have linked the Charts. If they are chart objects they will use the PowerPoint formatting, only the data is linked. If they are picture objects they retain the Excel formatting as PowerPoint only sees them as images.

      Reply
  21. Thanks for this! How do I edit the code below to only update Links on a specific range of slides using VBA instead of looping through Each PPTSlide (which takes forever in a 400 page deck)? Additionally, it is a collaborative deck and I don’t want to update other team member’s slides with tables/charts/objects inadvertently using the code.

    Reply
    • If you have the target workbooks opened, the refresh time is much less. I did a test recently on 16 pages. With workbooks closed the refresh was slow 2:40, but with the workbooks opened it was 0:02.

      Assuming the slides in the deck can change position, how are you going to keep track of which ones should be updated and which ones won’t?

      Reply
    • https://corporatefinanceinstitute.com/resources/excel/study/vba-loop/
      1. Do Until Loop
      2, Do While Loop
      3. For Loop.

      1. Do Until

      Option 1:
      Do [Until Condition]
      [Code block to execute]
      Loop

      Option 2:
      Do
      [Code block to execute]
      Loop [Until Condition]

      2. Do while:
      Do while [Condition Statement]
      [Code block to execute]
      Loop

      Or:

      Do While
      [Code block to execute]
      Loop [Condition statement]

      3. For

      For counter = start To end [Step value]
      [Code block to execute]
      Next [Counter]

      Reply
  22. re: https://exceloffthegrid.com/edit-links-in-powerpoint-using-vba/
    I’m not sure a msoLinkedChart is a shape.Type
    https://docs.microsoft.com/en-us/office/vba/api/office.msoshapetype
    This code didn’t work for me. Using ‘step in’ and a breakpoint (I’m a debugging novice and its clear nothing is more important in coding and it is the only thing never taught by anyone anywhere.) I found out the if condition was never true. I eventually figured out what the intermeddiate window is for and that it lists shap.type and then used ‘step into’ to learn that I only have msoChart, from the ones you listed and looking at file > info > edit links to files and scrolling through the links I think I learned those are all connected to charts, but you code fails in my circumstance because the replace function as written requires a linked Object.

    I have not yet thought of a way to logically get closer to the answer yet and dont know how long that would take.

    Can you enhance your answer above to include something about those in my situation who might spend a lot of time, seemingly trying to do what you describe, but is not exactly what the code tries to do.

    I dont know what what would be but if true, possibly,
    “This code only pertains to linked objects, but you may have images linked to excel files and see links when you go to file > info > edit links to files and not have any linked objects . Your objects maybe be/are …. and this code will not work on those. You will have to find such code elsewhere. Or I have code for this at this link … or you can modify my code by replacing … with … to change such links.

    Reply
  23. Hi there, the code works fine in local even after I changed msoLinkedChart to msoChart (because all my charts are embedded not linked), but when both of the excel and powerpoint files are in Sharepoint, the links are not able to updated to the new one. Do you have any idea on how to fix the code that throws error on the function “LinkFormat.SourceFullName”? Thank you in advance!

    Reply
    • I think it’s probably because SharePoint uses HTTP addresses, rather than file addresses.

      I’ve not tested the code on a SharePoint version. Maybe I should look into that.

      Reply
  24. Hi,

    it worked well, however it does not update the first link.
    I have 11 links in my ppt.
    2 of them are on the 1st slide and 1 is updated but the second is not.

    Do you have any clue why?

    Thanks
    Martin

    Reply
      • It was grupped with rectangle shape to prevend white outline taken from excel. When I ungrupped them, it started to work.
        Do you know how can I remove the white outline of the linked cell? I have white text, that is the reason why the outline is white.
        Thanks
        Martin

        Reply

Leave a Comment