Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hyperlink update to link to point in current doc

Status
Not open for further replies.

cdon

Programmer
Jul 5, 2003
17
GB
I am trying to replace hyperlinks to external files to links that point to within the same document. I have the following which I recorded but it only works for the one link when the cursor is placed in the link before starting the macro.

Selection.Range.Hyperlinks(1).Range.Fields(1).Result.Select
Set hyper = Selection.Range.Hyperlinks(1)
MsgBox hyper.address
hyperString = hyper.address
Selection.Range.Hyperlinks(1).Delete
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, address:="",SubAddress:=hyperString
Selection.Collapse Direction:=wdCollapseEnd

How would I go about changing this to work for every link in the file.

My hyperlinks are in fields so for example the field would be

HYPERLINK "Viewing_Logged_in_Users_.htm"
and I would want the link to point to the section in the file with the heading "Viewing Logged In Users".

This is easy through the menus as you just edit the hyperlink to point to the heading in the current doc but I cannot figure out how to do this automatically through VBA as I don't know how to access the heading field provided through manual use of the hyperlink edit menu.

I am using word 2000.

Hopefully this is clear and you can offer some guidance
Thanks
 
Hi,

I think that what you ought to do is insert a bookmark at each point that you want to hyperlink to and use the bookmark reference to perform the hyperlink -- no VBA needed.

Skip,
Skip@TheOfficeExperts.com
 
The process is to be automated by a macro as the document is a rather large 300+ pages, each page having many links on it and the document will be updated often.

Thanks for the suggestion though
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top