update multiple excel links

questforexcel

Board Regular
Joined
Jan 18, 2019
Messages
128
Office Version
  1. 2013
Platform
  1. Windows
this may be a bit of an overlap of MS Excel with MS powerpoint.

I need to update multiple links on a powerpoint from 2 excel files.

there are individual links displayed to each object, chart, graph in the edit links pop up.

Is there a way i could update them all at once without having to manually select the old and new file locations for each link? Any help would be greatly appreciated.

I saw some VBA codes online but it ran errors towards last stages. Sharing here for your reference and help.

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

The above command is where i am getting the errors. I added the same file name that I added at the start of the code but it keeps saying "Syntax Error" "Syntax Missing" Also this has the code for changing only one old file path to a new path , can I change multiple old file paths to new file paths in one 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 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



Any help would be much appreciated.

Thank you
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,223,706
Messages
6,173,998
Members
452,542
Latest member
Bricklin

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