Results 1 to 2 of 2
  1. #1
    Lounger
    Join Date
    Jan 2001
    Location
    Harrisburg, Pennsylvania, USA
    Posts
    44
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Change path to document

    Hello! We recently changed our drive mappings and have rendered previously saved documents somewhat useless. Asking users to manually change each link is not ideal... so I'm hoping I can create a macro they could use to automatically go through and add the proper network path.

    I tried a find/replace in the hyperlink field codes - but the entries aren't consistent.

    Any ideas out there?

    TIA ~

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    If you can't identify a pattern to search and replace on then it is going to be hard to create code to perform this task for you. The concept is pretty straightforward though.
    Code:
    Sub RepointHyperlinks()
      Dim aHL As Hyperlink, sOld As String, sNew As String, sPath As String
      sOld = "C:\Oldpath\"
      sNew = "H:\Newpath\"
      For Each aHL In ActiveDocument.Hyperlinks
        sPath = aHL.Address
        sPath = Replace(sPath, sOld, sNew)
        aHL.Address = sPath
      Next aHL
    End Sub
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

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