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
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