Updating PowerPoint links

femma

Board Regular
Joined
Jul 13, 2016
Messages
156
Hi!

I'm working with a PowerPoint that consists of links to an Excel-file. I would like the PowerPoint to ask every time from which Excel-file to take the links from. This because I have multiple Excel files that are the exact same, but with different names.
I found this (Change Source for Links to Excel charts from PowerPoint), but it doesn't work in my case.

Thank you very much :)
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Does someone know, why my code is not working, I've been struggling with this a loooong time now :D
Code:
Sub changeLinkTargets()

Dim pptSlide As Slide
Dim pptShape As Shape

Dim oldString As String
oldString = " C:\Users\viem152\Desktop\TYÖKALU8.7.xlsm"
Dim newString As String
newString = "C:\Users\viem152\Desktop\SVERIGE.xlsb"

For Each pptSlide In ActivePresentation.Slides
    For Each pptShape In pptSlide.Shapes
        If pptShape.Type = msoLinkedOLEObject Or pptShape.Type = msoLinkedPicture Then
            With pptShape.LinkFormat
                If InStr(1, UCase(.SourceFullName), UCase(oldString)) Then
                    .SourceFullName = Replace(.SourceFullName, oldString, newString)
                End If
            End With
        End If
    DoEvents
    Next pptShape
DoEvents
Next pptSlide
    DoEvents
    

End Sub


My links to the Excel file are PasteSpecial links.

Thank you for your help!
 
Upvote 0
The instring function returns a integer of where the string is found to start and 0 if it isnt found.
Your line
Code:
[COLOR=#333333]If InStr(1, UCase(.SourceFullName), UCase(oldString)) Then[/COLOR]
Should be
Code:
[COLOR=#333333]If InStr(1, UCase(.SourceFullName), UCase(oldString)) > 0 Then[/COLOR]
This will evaluate to True or False and then make the if statement work for you
I don't believe it ever gets evaluated to true and change the sourcefile.
 
Upvote 0

Forum statistics

Threads
1,223,803
Messages
6,174,689
Members
452,577
Latest member
Filipzgela

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