Replacing Linked Objects Source

gdel02

New Member
Joined
Apr 2, 2014
Messages
9
I've been using this code for a while now with some bugs every now and then:

Code:
Sub UpdateSheet()    Dim sld As Slide
    Dim sh As Shape
    Dim strNms As String
    Dim intI As Integer
    Dim strNewPath
    Dim ExcelFile
    Dim exl As Object
    Set exl = CreateObject("Excel.Application")
     
     'Open a dialog box to promt for the new source file.
    ExcelFile = exl.Application.GetOpenFilename(, , "Select Excel File")
    For Each sld In ActivePresentation.Slides
        For Each sh In sld.Shapes
            If sh.Type = msoLinkedOLEObject Then
                With sh.LinkFormat
                    strNms = .SourceFullName
                    intI = InStr(1, strNms, "!")
                    strNewPath = ExcelFile & Mid(strNms, intI, Len(strNms) - intI + 1)
                    .SourceFullName = strNewPath
                End With
            End If
        Next sh
    Next sld
    ActivePresentation.UpdateLinks
End Sub

The problem is, linked objects also contain a section within brackets, for example: [MyDocument.xlsm]Chart 1.
The code above, changes the string all up until !, but does not change the section within brackets also.

Any recommendations on how to loop for that section or any better code?

Thanks in advance!
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hello i wanted to ask if you were able to solve this problem, i having same issue and when updating links only part gets updated and the section within brackets stays unchanged. Thank you very much
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,893
Members
449,097
Latest member
dbomb1414

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