Automated List of Cross References in a Document

L

Lambertdl

I have a number of reasonably large documents--technical reports, each
consisting of 80 or more pages, and each with quite a few figures. The
figures all have captions, which made it easy to generate a list of figures
immediately following the TOC. The text of the documents contains cross
references to some (but not all) of the figures. I am looking for a means
(maybe a macro) of automatically generating a "report" of cross references to
figures, and the pages on which these cross references appear. This report
is intended to be a proofing tool. It could be generated as the last page of
the document. The purpose is to ensure that each figure in the document is
referenced in the body of the document at least one time.

I am a novice at writing macros, and have been unable to solve this problem
on my own. Has anyone else tried to develop a solution to this type of
problem?

Using WORD 2007 on a VISTA OS.
 
J

Jay Freedman

I have a number of reasonably large documents--technical reports, each
consisting of 80 or more pages, and each with quite a few figures. The
figures all have captions, which made it easy to generate a list of figures
immediately following the TOC. The text of the documents contains cross
references to some (but not all) of the figures. I am looking for a means
(maybe a macro) of automatically generating a "report" of cross references to
figures, and the pages on which these cross references appear. This report
is intended to be a proofing tool. It could be generated as the last page of
the document. The purpose is to ensure that each figure in the document is
referenced in the body of the document at least one time.

I am a novice at writing macros, and have been unable to solve this problem
on my own. Has anyone else tried to develop a solution to this type of
problem?

Using WORD 2007 on a VISTA OS.

Start here and tweak as needed:

Sub CrossRefReport()
Dim cRef As Field
For Each cRef In ActiveDocument.Fields
If (cRef.Type = wdFieldRef) And _
(InStr(cRef.Code, "_Ref")) Then
ActiveDocument.Range.InsertAfter _
cRef.Result.Text & vbTab & _
cRef.Result.Information( _
wdActiveEndAdjustedPageNumber) _
& vbCr
End If
Next
End Sub

What this does: The For loop picks out each field in the document
(because cross-references are fields). If the current field is a REF
field and it refers to a hidden bookmark whose name starts with
"_Ref", then it's a cross-reference.

When a field satisfies that condition, the InsertAfter statement puts
the text of the cross-reference, a tab, the page number, and a
paragraph mark at the end of the document.
 

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

Top