Hi =?Utf-8?B?S2hvc2hyYXZhbg==?=,
It is possible to go to reference by Ctrl+Clicking the cross-reference. IS
the vise-versa also possible?
I have a figure and made a caption for it and numbered it by caption. I want
to know if I have cross-referenced it in the body of my text or not.
No, this is not possible. At least, it's not a feature built into Word. The
reason it works in the one direction is that the cross-reference is generated
by a field. (You can view all the fields in a document by pressing Alt+F9 to
toggle the field code view). A field is dynamic, and so can support things like
hyperlinking. This is not the case for the "plain text" in your document.
When you create a cross-reference to anything other than a bookmark (a heading,
a numbered item), Word places a hidden bookmark around the item. You can see
this by going to Insert/Bookmark and clicking a few times on the "Hidden"
checkbox. You should see things like _Ref139862505. These will correspond to
what you see in cross-reference fields, for example: { REF _Ref139862505 \h }
You can use this principle to create a macro that will do what you'd like.
Here's a bit of sample code that demonstrates the principle. It hasn't been
thoroughly tested; it does work if I have the selection in a Heading. You could
assign it to a toolbar button or keyboard shortcut.
Sub GoToCrossReference()
Dim doc As Word.Document
Dim rng As Word.Range
Dim s As String
Dim fld As Word.Field
Dim bFound As Boolean
Set doc = ActiveDocument
Set rng = Selection.Range.Paragraphs(1).Range
rng.TextRetrievalMode.IncludeHiddenText = True
If rng.Bookmarks.Count < 1 Then GoTo SubEnd
s = rng.Bookmarks(1).Name
For Each fld In doc.Fields
If fld.Type = wdFieldRef Then
If InStr(fld.Code.Text, s) Then
fld.Select
bFound = True
Exit For
End If
End If
Next
SubEnd:
If Not bFound Then MsgBox "Could not find a reference"
End Sub
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail
