Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7282
  • Last Modified:

Edit Multiple Links in PowerPoint from Excel with VBA

Experts, I have searched and searched for months for an answer...

I have one PowerPoint presentation template that will be distributed to multiple people to their desktops and a multitude of paths. It might even be renamed by the user. The slides are linked to multiple tables and graphs within one Excel file that could also be renamed by the user to reflect the client name.

(1) Is there a way to have the user open a form or something within the PowerPoint template and change the Excel file name and path name with ease to update the links. Is there VBA code that would accomplish this?

(2) Bonus: Ideally, the links would embed after this action with a prompt to rename the file, but I know I'm asking for a miracle. Is there VBA code that would accomplish this?
0
toddnchristy
Asked:
toddnchristy
1 Solution
 
Rgonzo1971Commented:
Hi,

pls try

Sub Macro()

    Set XL = CreateObject("Excel.Application")
     
    XLFile = XL.Application.GetOpenFilename(, , "Select Excel File")
    For Each sld In ActivePresentation.Slides
        For Each shp In sld.Shapes
            If shp.Type = msoLinkedOLEObject Then
                With shp.LinkFormat
                    strName = .SourceFullName
                    intIdx = InStr(1, strName, "!")
                    If intIdx > 0 Then
                        strNewPath = XLFile & Mid(strName, intIdx, Len(strName) - intIdx + 1)
                    Else
                        strNewPath = XLFile
                    End If
                    .SourceFullName = strNewPath
                End With
            End If
        Next shp
    Next sld
set XL = Nothing
End Sub

Open in new window

Regards
0
 
toddnchristyAuthor Commented:
Works really well! Thank you so much!

The caution to others is that it take a while to loop through when you have multiple links—even to the same file.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now