Hi,
I am currently experiencing a problem when I try to run my VBA code in Powerpoint.
For context, I want to change my sources as they are all linked to an Excel that has changed location.
I have over 100 charts, so over 100 links to change. To avoid doing it manually, I tried a VBA code but when I want to run it, nothing happens.
PS: For the record, my file is now on SharePoint
The code is:
Thanks in advance.
I am currently experiencing a problem when I try to run my VBA code in Powerpoint.
For context, I want to change my sources as they are all linked to an Excel that has changed location.
I have over 100 charts, so over 100 links to change. To avoid doing it manually, I tried a VBA code but when I want to run it, nothing happens.
PS: For the record, my file is now on SharePoint
The code is:
VBA 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 = "Old File Path"
'The new file path as a string (the text to replace with)
newFilePath = "New File Path"
'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
Thanks in advance.
Last edited by a moderator: