Excel Macro to change powerpoint links

seenai

Board Regular
Joined
Mar 31, 2013
Messages
54
Hi,

I have a Powerpoint File, which has many Excel linked linked Charts. Now the folder name and Excel File names are changed.

I need a macro to
a) list all the links of the powerpoint file.
b) I want to update the new link.

Help me by a macro to do so.
Thanks in advance.

Regards,

B.Srinivasa Rao
 

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.
Hi

This is the first part, a PowerPoint code that lists the links. According to your title, do you prefer to run this from Excel?


Code:
' PowerPoint module
Sub PowerPointLinks()
Dim pptPres As Presentation, pptSlide As Slide, pptShape As Shape, s$
Set pptPres = ActivePresentation
s = ""
For Each pptSlide In pptPres.Slides
    For Each pptShape In pptSlide.Shapes
        If pptShape.Type = msoLinkedPicture Or pptShape.Type = msoLinkedOLEObject Then _
        s = s & pptShape.LinkFormat.SourceFullName & vbLf
    Next
Next
MsgBox s
pptPres.UpdateLinks
End Sub
 
Last edited:
Upvote 0
Hi

This is the first part, a PowerPoint code that lists the links. According to your title, do you prefer to run this from Excel?


Code:
' PowerPoint module
Sub PowerPointLinks()
Dim pptPres As Presentation, pptSlide As Slide, pptShape As Shape, s$
Set pptPres = ActivePresentation
s = ""
For Each pptSlide In pptPres.Slides
    For Each pptShape In pptSlide.Shapes
        If pptShape.Type = msoLinkedPicture Or pptShape.Type = msoLinkedOLEObject Then _
        s = s & pptShape.LinkFormat.SourceFullName & vbLf
    Next
Next
MsgBox s
pptPres.UpdateLinks
End Sub

Hi,

Thanks for your response.

Yes. I want to update from Excel Macro.

a) I will provide Path of PPT --> Excel Macro to list the Links in PPT
b) I will enter the New File Path in Next Column --> Macro to update the Links.

Hope I am clear.
 
Upvote 0
This version is an Excel macro that lists the links starting at cell L20, and updates them with the information entered at column M, starting at M20.
The PowerPoint file path is retrieved from cell K18.

Code:
' Excel module
Dim obppt As Object, pres As Presentation, sl As Slide, sh As PowerPoint.shape, r As Range

Sub ListLinks()
Set obppt = CreateObject("PowerPoint.Application")
obppt.Visible = True
obppt.Presentations.Open CStr([k18])
Set pres = obppt.ActivePresentation
Set r = [L20]
For Each sl In pres.Slides
    For Each sh In sl.Shapes
        If sh.Type = msoLinkedPicture Or sh.Type = msoLinkedOLEObject Then
            r = sh.LinkFormat.SourceFullName
            Set r = r.Offset(1)
        End If
    Next
Next
UpdateLinks
End Sub

Sub UpdateLinks()
Dim result
For Each sl In pres.Slides
    For Each sh In sl.Shapes
        If sh.Type = 11 Or sh.Type = 10 Then
            result = WorksheetFunction.VLookup(sh.LinkFormat.SourceFullName, _
            [L20].CurrentRegion, 2, False)
            If Len(result) > 0 Then sh.LinkFormat.SourceFullName = result
        End If
Next sh, sl
pres.UpdateLinks
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,487
Messages
6,113,943
Members
448,534
Latest member
benefuexx

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