Any cross-reference field can act as a hyperlink, by adding the hyperlink switch (ie \h) when you create it. Alternatively, you can
add the switch later by selecting the cross-reference field and pressing Shift-F9 to expose the field code, then adding '\h' at the
right end. Press F9 to update the field.
Do note that cross-reference fields acting as hyperlinks don't look any different to the surrounding text (ie not blue & underlined
text) as in ordinary hyperlinks. If you want the cross-reference field to look like a hyperlink, format the 'R' in 'REF' or 'P' in
'PAGEREF', depening on the type of cross-reference, and add '\* Charformat' to the field code, before the '\h'.
--
Cheers
macropod
[Microsoft MVP - Word]
"Elena Bulaeva" <elena....@gmail.com> wrote in message news:579993a6-f8e8-4063...@o36g2000vbl.googlegroups.com...
We don't need the cross-reference field to look like a hyperlink. We
need to change cross-reference to hyperlinks, cause the method of
adding links (as hyperlinks — Insert - hyperlinks - Place In this
document) is very important for future work with this documents.
We want to find a quick method of replacing links in many documents.
Replacing links by hand will take too much time.
Since cross-references can function the same way as hyperlinks, I don't understand why you need a hyperlink, as such - especially
since inserting hyperlinks is more complicated (the process is fully explained in Word's Help file).
--
Cheers
macropod
[Microsoft MVP - Word]
"Elena Bulaeva" <elena....@gmail.com> wrote in message news:c0c82326-d310-4cb6...@z28g2000vbl.googlegroups.com...
Hi, macropod. Thank you for your replay.
We don't need the cross-reference field to look like a hyperlink. We
need to change cross-reference to hyperlinks, cause the method of
adding links (as hyperlinks � Insert - hyperlinks - Place In this
This documents will be translated in one of the Translation memory
systems, which can work correctly with hyperlinks only. This
documents have already contaned cross-references.
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.
--
Cheers
macropod
[Microsoft MVP - Word]
"Elena Bulaeva" <elena....@gmail.com> wrote in message news:25b180d7-d6eb-4fc9...@a6g2000vbp.googlegroups.com...
I'm after almost exactly the same solution as elena and stumbled over
your code. The problem I have is the following: I have two
cross-references one after another and when I run your macro, it
eliminates the space between them. I tried working through your code,
but i can't quite figure it out. Could you please help me on that?
best regards
--
darksinister
------------------------------------------------------------------------
darksinister's Profile: http://www.thecodecage.com/forumz/member.php?userid=971
View this thread: http://www.thecodecage.com/forumz/showthread.php?t=137790
Change:
With Selection
.Cut
to
With Selection
.InsertAfter " "
.Cut
--
Cheers
macropod
[Microsoft MVP - Word]
"darksinister" <darksinis...@thecodecage.com> wrote in message news:darksinis...@thecodecage.com...
--
Cheers
macropod
[Microsoft MVP - Word]
"darksinister" <darksinis...@thecodecage.com> wrote in message news:darksinis...@thecodecage.com...
>