Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Khoshravan Khoshravan is offline
external usenet poster
 
Posts: 118
Default Find cross-reference from reference

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.
--
Rasoul Khoshravan Azar
Civil Engineer, Osaka, Japan
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Cindy M -WordMVP- Cindy M  -WordMVP- is offline
external usenet poster
 
Posts: 370
Default Find cross-reference from reference

Hi ?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 :-)

  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Khoshravan Khoshravan is offline
external usenet poster
 
Posts: 118
Default Find cross-reference from reference

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?!?
--
Rasoul Khoshravan Azar
Civil Engineer, Osaka, Japan


"Cindy M -WordMVP-" wrote:

Hi ?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 :-)


  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Cindy M -WordMVP- Cindy M  -WordMVP- is offline
external usenet poster
 
Posts: 370
Default Find cross-reference from reference

Hi ?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 :-)

  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Khoshravan Khoshravan is offline
external usenet poster
 
Posts: 118
Default Find cross-reference from reference

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.
--
Rasoul Khoshravan Azar
Civil Engineer, Osaka, Japan


"Cindy M -WordMVP-" wrote:

Hi ?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 :-)




  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Khoshravan Khoshravan is offline
external usenet poster
 
Posts: 118
Default Find cross-reference from reference

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?

--
Rasoul Khoshravan Azar
Kobe University, Kobe, Japan


"Cindy M -WordMVP-" wrote:

Hi ?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 :-)


  #7   Report Post  
Posted to microsoft.public.word.docmanagement
Cindy M -WordMVP- Cindy M  -WordMVP- is offline
external usenet poster
 
Posts: 370
Default Find cross-reference from reference

Hi ?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 :-)

  #8   Report Post  
Posted to microsoft.public.word.docmanagement
Khoshravan Khoshravan is offline
external usenet poster
 
Posts: 118
Default Find cross-reference from reference

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

  #9   Report Post  
Posted to microsoft.public.word.docmanagement
Cindy M -WordMVP- Cindy M  -WordMVP- is offline
external usenet poster
 
Posts: 370
Default Find cross-reference from reference

Hi ?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 the macro does is check whether the current selection is inside at least one

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

  #10   Report Post  
Posted to microsoft.public.word.docmanagement
lisak lisak is offline
external usenet poster
 
Posts: 39
Default Find cross-reference from reference

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

"Khoshravan" wrote:

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.
--
Rasoul Khoshravan Azar
Civil Engineer, Osaka, Japan

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
cross reference inserts entire figure digitig Microsoft Word Help 4 October 10th 14 11:56 AM
Cross reference dialog box should allow preferencing keithinoz Tables 0 January 31st 06 03:17 AM
Cross reference - text to figure to text K singh Microsoft Word Help 0 April 14th 05 02:53 PM
cross reference bookmark annoyed word user Microsoft Word Help 0 February 14th 05 09:21 PM
Cross reference to custom caption type Ton Microsoft Word Help 2 February 9th 05 03:04 PM


All times are GMT +1. The time now is 09:39 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"