Changing Hyperlink Addresses

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

When preparing Word documents for Intranet use, I set them
up in my C: drive
in a set of folders that match the folder structure on the
Intranet server.
Hyperlinks between documents are normally set up
as 'relative' links.

Digital copies of draft documents are sometimes passed to
others, may be
edited by them (but without touching the links) and then
re-saved locally
(usually under a new file name). When returned to me, I
put them back into
the original folder. At this point, the links should be as
they were
originally and be usable. In pre-XP days, this used to be
the case but I
have now found that, on at least a couple of occasions
since moving to full
use of XP, the links in the returned document have changed
to a path
structure incorporating folder names belonging to the
editor's PC. This
means that, to get the links usable again, they all have
to be re-edited to
eliminate the rogue elements in the path.

This is tiresome (and there is the risk that one or more
might get
overlooked) -- how can I stop it happening?
 
Hi Paul,

I don't know how you can stop it form happening, but this macro will
simplify the task of restoring them

' Macro created 26/10/01 by Doug Robbins to update links in a document
'
Dim alink As Field, linktype As Range, linkfile As Range
Dim linklocation As Range, i As Integer, j As Integer, linkcode As Range
Dim Message, Title, Default, Newfile
Dim counter As Integer



counter = 0
For Each alink In ActiveDocument.Fields
If alink.Type = wdFieldLink Then

Set linkcode = alink.Code
i = InStr(linkcode, Chr(34))
Set linktype = alink.Code
linktype.End = linktype.Start + i
j = InStr(Mid(linkcode, i + 1), Chr(34))
Set linklocation = alink.Code
linklocation.Start = linklocation.Start + i + j - 1
If counter = 0 Then
Set linkfile = alink.Code
linkfile.End = linkfile.Start + i + j - 1
linkfile.Start = linkfile.Start + i
Message = "Enter the modified path and filename following this
Format " & linkfile
Title = "Update Link"
Default = linkfile
Newfile = InputBox(Message, Title, Default)
End If
linkcode.Text = linktype & Newfile & linklocation
counter = counter + 1
End If
Next alink


--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
Back
Top