Why is this code to edit links so slow?
Results 1 to 2 of 2

Thread: Why is this code to edit links so slow?
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Nov 2013
    Post Thanks / Like
    0 Post(s)
    0 Thread(s)

    Post Why is this code to edit links so slow?

    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:

    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)
        Next oshp
    Next osld

  2. #2
    Board Regular Rijnsent's Avatar
    Join Date
    Oct 2005
    Utrecht, Holland
    Post Thanks / Like
    1 Post(s)
    0 Thread(s)

    Default Re: Why is this code to edit links so slow?

    Hi z3115,
    I found this code:
    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,
    You can't post attachments here, but you can help me helping you by posting a screen shot directly in your post with any of those tools.
    Otherwise use dropbox/google drive/etc to get your file accross (not preferred). For code, put it inside these tags: [ CODE][/CODE]. Do check the forum rules.
    Finally, please show that you made an effort to solve your problem: Yes, I like to help, but am not going to do your job.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts