Results 1 to 4 of 4

Altering Hyperlinks Macro

Threaded View

  1. #1
    Registered User
    Join Date
    05-14-2009
    Location
    Barry, Wales
    MS-Off Ver
    Excel 2002
    Posts
    4

    Altering Hyperlinks Macro

    Can anyone help. I am new to all this and have a problem that is simple to solve but I am stuck.

    I have numerous worksheets with thumbnail images inserted and hyperlinked to the full size image. I need to edit all the hyperlinks at once as the file addresses have changed and I dont want to edit them manually.

    I have found a code to run which works well (see below) which specifies the old folder structure and allows you to replace it with a new one.

    my folder structure to the files is as follows:

    c:\folder a\folder b\variable folder name\file name

    How can i specify the variable folder names without having to alter it every time. The replace ment folder name will be the same for all the links. I am sure it is easy but my limited knowledge has failed me.
    Sub UpdateHyperlinks()
    
        Const sOldPath  As String = "c:\folder a\folder b\variable folder name\"
        Const sNewPath  As String = "c:\folder a\folder b\new name\"
    
        Dim sNewAddress As String
        Dim hyp         As Hyperlink
    
        For Each hyp In ActiveSheet.Hyperlinks
            If InStr(hyp.Address, sOldPath) <> 0 Then
                sNewAddress = Replace(hyp.Address, sOldPath, sNewPath)
                hyp.Address = sNewAddress
            End If
        Next hyp
    
    End Sub
    Last edited by Leith Ross; 05-07-2011 at 01:26 PM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1