Hi Elena,
I'm not sure that Word exposes any attributes from REF & PAGREF fields, etc that can be interrogated via vba and incorporated into a
HYPERLINK field. Nevertheless, you may be able to achive what you're after by embedding the cross-reference fields in hyperlink
fields. For that, you could use code like:
Sub HyperlinkXRefs()
Dim i As Integer, RngFld As Range
ActiveWindow.View.ShowFieldCodes = True
With ActiveDocument
For i = .Fields.Count To 1 Step -1
With .Fields(i)
If .Type = wdFieldRef Or .Type = wdFieldPageRef Then
.Select
With Selection
.Cut
.Fields.Add Range:=.Range, Type:=wdFieldHyperlink, Text:="\l", PreserveFormatting:=False
.MoveEnd wdWord, 1
Set RngFld = .Range
.Collapse wdCollapseEnd
.Move wdCharacter, -1
.Paste
RngFld.Collapse wdCollapseStart
End With
End If
End With
Next
.Fields.Update
End With
ActiveWindow.View.ShowFieldCodes = False
End Sub
If that doesn't achieve what you're after, I suspect you'll have to go through the document manually replacing the cross-references
with hyperlinks.
You may be concerned about my references to cross-reference fields in hyperlink fields in the above. The reason is that this is how
Word stores cross-references and hyperlinks.
Note too that, if a cross-reference field is already embedded in another field and you run the above code, you'll end up with a
hyperlinked cross-reference embedded in that field - running the code twice, for example, will produce that effect.