questforexcel
Board Regular
- Joined
- Jan 18, 2019
- Messages
- 128
- Office Version
- 2013
- Platform
- 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
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