Editing Hyperlinks in Word

D

Dale

I have a large amount of files with hyperlinks (one to three per file) that link to another folder with a large amount of files. All the files the hyperlinks point to are Word documents with .doc extensions. Now, I have to go through all these files and change the hyperlinks to another folder with the same file names, but that are saved as HTML files with the extension .html.

I hope someone out there knows of a faster way of doing this, so I don't have to go to each hyperlink in each file and edit it. I tried using the Find & Replace feature - finding *.doc and replacing it with *.html; but that didn't work

Any help would be appreciated
 
M

macropod

Hi Dale,

You'll need to change both the file's extension and the file path. To do the
latter, download the document at:
http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=261488
(url all one line)
and run the macro in it against each file that needs updating.

Cheers


Dale said:
I have a large amount of files with hyperlinks (one to three per file)
that link to another folder with a large amount of files. All the files the
hyperlinks point to are Word documents with .doc extensions. Now, I have to
go through all these files and change the hyperlinks to another folder with
the same file names, but that are saved as HTML files with the extension
..html.
I hope someone out there knows of a faster way of doing this, so I don't
have to go to each hyperlink in each file and edit it. I tried using the
Find & Replace feature - finding *.doc and replacing it with *.html; but
that didn't work.
 
D

Doug Robbins - Word MVP

You could modify the following macro

' 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 post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
Top