Find cross-reference from reference

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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 :-)
 
Thanks Cindy. It helped a lot.
You exempted bookmarks. Does it mean, for them it is possible to go from
reference to corss-reference?
I have a fear of approaching Macros (I don't no exactly why, Its difficulty
to understand, fear of system crashh) so basically any solution which ends to
Macros, I simply gave up?!?
 
Thanks Cindy. It helped a lot.
You exempted bookmarks. Does it mean, for them it is possible to go from
reference to corss-reference?
I have a fear of approaching Macros (I don't no exactly why, Its difficulty
to understand, fear of system crashh) so basically any solution which ends to
Macros, I simply gave up?!?
 
Hi =?Utf-8?B?S2hvc2hyYXZhbg==?=,
You exempted bookmarks. Does it mean, for them it is possible to go from
reference to corss-reference?
I have a fear of approaching Macros (I don't no exactly why, Its difficulty
to understand, fear of system crashh) so basically any solution which ends to
Macros, I simply gave up?!?
No, bookmarks aren't any different, really. Sorry about the confusion on that
point. It's just that I was concentrating on the "hidden bookmarks" that most
cross-references base on. It's comparatively rare to encounter people who even
know what bookmarks are and that they can be cross-referenced :-) Probably, the
same macro would also work for "plain vanilla" bookmarks, but I didn't test
that, yesterday.

I can understand (intellectually) your reluctance to "touch" macros. Along with
the reasons you cite, in recent years there's also been the concern about
viruses. But as soon as you want to do something that's not programmed into
Word, that's going to be your only recourse - or you do without.

My approach could also be used without a macro, it would just take a lot more
"grunt work". Click in the heading (or whatever) for which you want to find the
reference(s). Insert/Bookmark, make sure the "hidden" bookmarks (that start with
an _underscore) are displayed. Look at which one is selected - that should be
the bookmark name of the current text. To be sure, click "GoTo". Note the
bookmark name, then close the dialog box.

Press Alt+F9 so that the field codes are visible. Now Edit/Find and type (or use
copy/paste) the bookmark into the "Find" field. This should jump you to the
cross-reference.

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 :-)
 
Hi =?Utf-8?B?S2hvc2hyYXZhbg==?=,
You exempted bookmarks. Does it mean, for them it is possible to go from
reference to corss-reference?
I have a fear of approaching Macros (I don't no exactly why, Its difficulty
to understand, fear of system crashh) so basically any solution which ends to
Macros, I simply gave up?!?
No, bookmarks aren't any different, really. Sorry about the confusion on that
point. It's just that I was concentrating on the "hidden bookmarks" that most
cross-references base on. It's comparatively rare to encounter people who even
know what bookmarks are and that they can be cross-referenced :-) Probably, the
same macro would also work for "plain vanilla" bookmarks, but I didn't test
that, yesterday.

I can understand (intellectually) your reluctance to "touch" macros. Along with
the reasons you cite, in recent years there's also been the concern about
viruses. But as soon as you want to do something that's not programmed into
Word, that's going to be your only recourse - or you do without.

My approach could also be used without a macro, it would just take a lot more
"grunt work". Click in the heading (or whatever) for which you want to find the
reference(s). Insert/Bookmark, make sure the "hidden" bookmarks (that start with
an _underscore) are displayed. Look at which one is selected - that should be
the bookmark name of the current text. To be sure, click "GoTo". Note the
bookmark name, then close the dialog box.

Press Alt+F9 so that the field codes are visible. Now Edit/Find and type (or use
copy/paste) the bookmark into the "Find" field. This should jump you to the
cross-reference.

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 :-)
 
Thanks for your valuable information.
Going through your explanation I feel the pain of studying Macros. I think I
have to change my mind and approach it.
Thanks for all your contribution.
 
Thanks for your valuable information.
Going through your explanation I feel the pain of studying Macros. I think I
have to change my mind and approach it.
Thanks for all your contribution.
 
Dear Cindy
Thanks for your info. Sorry for late response. Today almost after one month
I find time and mood to work on the Macro you sent for finding
cross-references from references. In your reply, you have mentioned that: â€it
does work if I have the selection in a Headingâ€. I copy-paste your Macro and
Run it and it says: "couldn't find a reference". But I have.
I think it has something to with "Heading" you mentioned.
What I understand from your post is that your Macro will look for
cross-references only in Headings and not any place else. Am I right?
Isn't it possible to modify the Macro to look in whole area of the file for
cross-references?
 
Hi =?Utf-8?B?S2hvc2hyYXZhbg==?=,
Thanks for your info. Sorry for late response. Today almost after one month
I find time and mood to work on the Macro you sent for finding
cross-references from references. In your reply, you have mentioned that: â€it
does work if I have the selection in a Headingâ€. I copy-paste your Macro and
Run it and it says: "couldn't find a reference". But I have.
I think it has something to with "Heading" you mentioned.
What I understand from your post is that your Macro will look for
cross-references only in Headings and not any place else. Am I right?
Isn't it possible to modify the Macro to look in whole area of the file for
cross-references?
No, the macro isn't specific for Headings, that's just the only scenario I tested
for. You didn't provide any information about what you cross-reference, so I took
the most common scenario.

What the macro does is check whether the current selection is inside at least one
bookmark. If it is, it takes the first bookmark's name, looks at every field in the
document to see if the bookmark name is part of the field. If it can't find a
match, you get the message.

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 :-)
 
Dear Cindy
Thanks for you reply.
First of all, my references are Figure numbers (3 figures) and Table numbers
(4 tables) which are inserted by caption. then I cross referenced them in the
body of the paper.
Second, I couldn't understand "current selection " in your reply:
What the macro does is check whether the current selection is inside at least one
What do you mean by current selection?

TIA
 
Hi =?Utf-8?B?S2hvc2hyYXZhbg==?=,
First of all, my references are Figure numbers (3 figures) and Table numbers
(4 tables) which are inserted by caption. then I cross referenced them in the
body of the paper.
Second, I couldn't understand "current selection " in your reply:
I just tested on a Figure n cross-reference and it worked...
What do you mean by current selection?
Current selection = Where the cursor is blinking. It has to be within the bookmarked
text. For a Figure n or Table n somewhere in that text (what you see in the
cross-reference).

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 :-)
 
I don't know if you'll get this, since you asked this question in 2006. In
any event, when you click on the cross-ref link, you go to the target, as you
know. if you use Shift+F5, you'll return to the last location you were at in
the doc. Hope you find this useful.

Lisa
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top