Why is this code to edit links so slow?

z3115

Board Regular
Joined
Nov 1, 2013
Messages
71
Hello, I wrote some code to look for external links to "file A" and replace them with links to "file B". The code is in PowerPoint, and in this PowerPoint file I have about 25 "objects" linked to excel (the objects are primarily just cells from excel pasted into PowerPoint as linked objects).

The code works, but it takes 7-8 minutes to run. Any idea why it takes so long or how to make it faster? It seems as all it's doing is finding and replacing text, so I'm confused as to why it takes so much time.

Relevant portion of code:

Code:
Dim newPath As String
Dim templateHome As String
Dim oshp As Shape
Dim osld As Slide
Dim vizFile As Workbook
Dim vizFname As String
Dim replacethis As String
Dim replacewith As String


'3. Update links:
'(Replace links to template file link with links to new copy of the file)


replacethis = templateHome & vizFname
replacewith = newPath & "\" & vizFname
On Error Resume Next
For Each osld In ActivePresentation.Slides
   For Each oshp In osld.Shapes


     oshp.LinkFormat.SourceFullName = Replace(oshp.LinkFormat.SourceFullName, replacethis, replacewith)
     oshp.LinkFormat.Update


    Next oshp
Next osld
 

Some videos you may like

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Rijnsent

Well-known Member
Joined
Oct 17, 2005
Messages
1,277
Office Version
365
Platform
Windows
Hi z3115,
I found this code:
https://exceloffthegrid.com/edit-links-in-powerpoint-using-vba/
The main difference seems to be that that code changes the links and only at the end runs the .update command. I assume that it's much quicker to change all the links and update once vs running the 25 update commands.
Hope that pointer helps,
Koen
 

Watch MrExcel Video

Forum statistics

Threads
1,102,448
Messages
5,486,958
Members
407,574
Latest member
Greso

This Week's Hot Topics

Top