Update OLE Paths

enswitzer

New Member
Joined
Mar 23, 2013
Messages
14
I have a powerpoint presentation that pulls multiple links from Excel. In order to update these links when the path changes I am using a macro I found online, but was hoping someone could help me with a couple of questions.

Code:
Sub ChangeOLELinks()' Note: this will only work in PPT 2000 and later    
Dim oSld As Slide    
Dim oSh As Shape    
Dim sOldPath As String    
Dim sNewPath As String    ' EDIT THIS TO REFLECT THE PATHS YOU WANT TO CHANGE    
' Include just the portion of the path you want to change    
' For example, to change links to reflect that files have moved from    
' \\boss\p-drive\temp\*.* to    
' \\boss\Q-drive\temp\*.*    

sOldPath = "\\boss\p-drive\"    
sNewPath = "\\boss\q-drive\"    
On Error GoTo ErrorHandler    
For Each oSld In ActivePresentation.Slides        
For Each oSh In oSld.Shapes            ' Change only linked OLE objects            
If oSh.Type = msoLinkedOLEObject Then                
On Error Resume Next                ' Verify that file exists                
If Len(Dir$(Replace(oSh.LinkFormat.SourceFullName, sOldPath, sNewPath))) > 0 Then                     
oSh.LinkFormat.SourceFullName = Replace(oSh.LinkFormat.SourceFullName, sOldPath, sNewPath)               
Else  MsgBox("File is missing; cannot relink to a file that isn't present")                
End If                
On Error GoTo ErrorHandler             
End If        
Next    ' shape    
Next    ' slide    
MsgBox("Done!")NormalExit:    

Exit SubErrorHandler:    MsgBox("Error " & err.number & vbcrlf & err.description)    
Resume NormalExit
1. Should this macro take an excessive amount of time to run (sometimes over 5 minutes) - is there a way to speed it up?

2. I keep getting an error message "File is missing; cannot relink to a file that isn't present" however I have no way of identifying which slide or shape it is getting stuck on. Once I confirm the error it does continue on and run the rest of the macro to completion, but I would like to know which link is not updating and can't seem to find it. Is there a way?
 
Last edited:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,223,214
Messages
6,170,774
Members
452,353
Latest member
strainu

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