VBA to change source of links in PowerPoint

I have a PowerPoint file (Office 2007) that has Linked Object on each slide to various excel files.  I need to move the Excel source files to a different folder location.  Currently they sit in "\\serverXY\DataFiles" and I need to move them to "\\serverAQ\DataFiles".

Since I have doesn't of slides, instead of updating these links manual, I'm wondering if there is a way to update all the links programmaticly through VBA?  Here's the other thing.  I don't need to update the WHOLE link, only the portion of the link that starts with "\\serverXY\DataFiles" should be changed to "\\serverAQ\DataFiles".

Any ideas?  Thanks!
KP_SoCalAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

atomsheepCommented:
Try this code. It will iterate through all slides in the active presentation, check all the shapes to see if they are linked objects or pictures, and then modify the target. Note that the oldString and newString are case sensitive.
Sub changeLinkTargets()

Dim pptSlide As Slide
Dim pptShape As Shape

Dim oldString As String
oldString = "\\serverXY\DataFiles"
Dim newString As String
newString = "\\serverAQ\DataFiles"

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

End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KP_SoCalAuthor Commented:
Wow, this looks like it's going to do the trick!  I'll try it out tomorrow morning and post my results.  Thanks!
KP_SoCalAuthor Commented:
Fantastic!  This worked and will save me HOURS of work!!!  Thanks so much!!!!
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

KP_SoCalAuthor Commented:
This solution deserves 1000 points!
atomsheepCommented:
Glad it worked. Thanks for asking this question, it helped me to learn too!
Heinz SchremCommented:
Hello
I find this solution also very helpful and excellent.
Does this VBA solution also work for Powerpoint/Excel 2010?
I do not see anything happening when implementing this code (and changing to my server/folder/... names).
Thanks a lot
Best regards
Heinz
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft PowerPoint

From novice to tech pro — start learning today.