This is not exactly what you want, but may give you a few ideas:
' 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

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> Hi,
>
[quoted text clipped - 19 lines]
>
> Many thanks.
Oz - 14 Jul 2005 23:46 GMT
Ok. Looks complicated, but I'll give it a try! I had a go at writing a
method myself. Would this work at all?
Sub ConvertHLinks()
Dim i As Integer
Dim HLinkName As String
If ActiveDocument.Hyperlinks.Count > 0 Then
For i = 1 To ActiveDocument.Hyperlinks.Count
HLinkName = ActiveDocument.Hyperlinks(i).TextToDisplay
' Crop text???'
ActiveDocument.Hyperlinks(i).Address =
BookmarkSearch(HLinkName)
Next
MsgBox "All Done"
End If
End Sub
Function BookmarkSearch(HLinkName As String)
Dim oBookmark As Bookmark
Dim oBookmarkName As String
For Each oBookmark In ActiveDocument.Bookmarks
oBookmarkName = oBookmark.Name
If InStr(1, oBookmarkName, HLinkName, vbTextCompare) = 1 Then
Return oBookmarkName
End If
Next oBookmark
End Function
--------
The only bit I'm missing out is 'Crop text?'. If I have a phrase, eg.
add hyperlinks to thread (page 2-3), and I know that the bookmark is
stored under "add hyperlinks to thread", what method can I use on the
phrase to get rid of the (page 2-3) bit?
thanks again!
Doug Robbins - 15 Jul 2005 06:30 GMT
Use
Dim HlinkName As String
HlinkName = "add hyperlinks to thread (page 2-3)"
HlinkName = Left(HlinkName, InStr(HlinkName, "(") - 2)
MsgBox HlinkName
The last line demonstrates the effect

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> Ok. Looks complicated, but I'll give it a try! I had a go at writing a
> method myself. Would this work at all?
[quoted text clipped - 41 lines]
>
> thanks again!
Oz - 15 Jul 2005 18:28 GMT
Thanks for your help, Doug, I really appreciate it.
I'm a bit confused how I'm supposed to run this script though. I put it
into a module window in VBA for the document I want to use. But when I
click play it says The Macros in this project are disabled. It says
this regardless of the security settings I use.
Oz - 15 Jul 2005 18:33 GMT
Sorry, my bad. I got past that. But when I run the macro I get an error
saying Run-time error '5'. Invalid procedure call or argument, on the
line:
ActiveDocument.Hyperlinks(i).Address = BookmarkSearch(HLinkName)
where BookmarkSearch is a function that takes the string HLinkName and
returns a string.