Cross-reference, insert footnote, doesn't update bug

U

UtopiaSoon

I'm working on several large papers and a thesis, and have noted the
following bug in Word 2007.

I understand how to use automatic footnoting, how to use cross-references to
repeat a footnote reference, and how to highlight text and press F9 to update
fields (cross-references) if a footnote is inserted or deleted. But, I have
noticed on a number of occasions that cross-referenced footnotes do not
properly update, and are left pointing to the wrong footnote. As an
incorrect footnote could be a big issue in any number of different
precise-writing settings, I wanted to figure out why this was happening.

I've been able to isolate that this _sometimes_ occurs when you are
inserting a footnote in front of one that you have cross-referenced, ie when
the footnote you insert has the same number as one you've cross-referenced
(so the cross-referenced footnote is increasing in value by 1, yet the
cross-reference does NOT increase by one but stays pointing to the newly
inserted footnote!!). I've been able to reproduce the error very
consistently when the cross-referenced footnote is footnote #1, and you
insert a footnote before it, the cross-referenced footnote will not update to
2 no matter what you do, it incorrectly stays on 1.

It can be very time consuming to check every footnote for cross-references
when you insert another with the same number. This is a serious bug, one
which I would think would make this product untrustable in many professional
environments.

It is amazing to me that I cannot find any other reference to this problem
in Word 2007 on the internet. Am I doing something wrong here? Is there an
easy solution besides painstakingly checking over 100s of citations?
 
U

UtopiaSoon

Track changes is not on.

In all cases where I've observed the bug, I've selected all and F9'd both
the text and the footnotes.
 
U

UtopiaSoon

Note also that I am able to reproduce this bug on several different machine
from a new document, where I insert a footnote in front of footnote 1, and
the cross-reference to footnote 1 stays on 1 after updating all fields.
 
L

Lene Fredborg

When you insert a cross-reference, Word creates a _Ref bookmark around the
item to which you refer.

I have tested what you describe in both Word 2003 and Word 2007 and I can
reproduce the problem. If you insert a footnote reference _immediately_ in
front of an existing footnote reference, it is understandable that the
problem occurs. Then the _Ref bookmark that was inserted around the first
footnote reference will expand to include the new footnote reference too. The
behavior is related to the cross-reference problems I have illustrated at:
http://www.thedoctools.com/index.php?show=wt_cross-reference_trouble

However, what seems to happen is that the _Ref bookmark sometimes will
expand to include the new footnote reference even if you leave a space and/or
one or more characters between the existing and the new footnote reference.
This should not happen…

I have tried whether I could find a “safe†way to prevent the problem. As
you also describe, the problem seems to be most persistent if you have a
cross-reference to the first footnote and insert a new footnote prior to
that. Actually, I found no “safe†way the insert a new footnote in that case.
The existing _Ref bookmark seems to be able to expand across any text found
between the two footnote references – i.e. the most “safe†method may be to
replace the cross-references to the original footnote 1. As regards other
footnotes, I found that you may be able to prevent the problem if you make
sure that a least a space is found between the existing footnote reference
and the cursor when you insert the new footnote. However, if you have _once_
inserted a new footnote reference _immediately_ to the left of an existing
footnote reference to which a cross-reference is found, the problem with the
expanded – and erroneous - _Ref bookmark seems to be sticky: even if you
delete the new footnote reference and insert a new one with at least a space
to separate it from the existing one, the “expanded†bookmark problem also
seems to occur for the new footnote reference – and then you may need to
replace cross-references to that footnote too. So all in all, I did not find
any “safe†methods – it will take some more experiments if possible at all.

In order to make it easier to find _Ref bookmarks that may be wrong, I made
the following macro which may help you isolate which cross-references you may
need to replace. The macro checks all bookmarks in the document. If the
bookmark name starts with “_Refâ€, it is checked whether that bookmark
includes more than one footnote. In that case the bookmark text is marked by
red highlight. Here is the macro:


Sub Footnotes_MarkProblemRefBookmarks()

Dim oBookmark As Bookmark
Dim nCount As Long

nCount = 0

For Each oBookmark In ActiveDocument.Bookmarks
With oBookmark
If Left(oBookmark.Name, 4) = "_Ref" Then
If .Range.Footnotes.Count > 1 Then
.Range.HighlightColorIndex = wdRed
nCount = nCount + 1
End If
End If
End With
Next oBookmark

MsgBox nCount & " _Ref bookmarks that include more than one footnote
reference were found and marked by red highlight.", vbOKOnly, "Result of _Ref
bookmark check"

End Sub

NOTE: The macro could be improved in many ways. When the macro finds a _Ref
bookmark that includes more than one footnote, it would be possible to make
the macro automatically change the _Ref bookmark to include only the last of
the footnotes (and thereby correct the problem). However, since _Ref
bookmarks are used for all types of cross-references, it may need a check by
a human eye to see whether a specific bookmark should be changed or not. The
macro could be improved so that it selects the bookmark, stops and asks what
to do. The version above can be used as a starting point.

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
U

UtopiaSoon

Thanks very much for the great response Lene.

Certainly a red highlight on potentially wrong cross references would be
some improvement to the situation. I'm running Word 2007 and I cannot get
that macro to work, it finds and highlights 0 _Refs when I have the problem
occuring in a document. I'm not very familiar with writing macros, perhaps
I'm doing something simple wrong...
 
L

Lene Fredborg

Since you see the message when the macro ends, I am quite sure you have
installed the macro correctly and that it runs. I tested the macro in Word
2007 and it worked correctly here (all erroneous bookmarks were found and
marked).

You could try this to find out whether the problem is actually caused by
erroneous _Ref bookmark(s) in your document:
Go to a cross-reference that you know is wrong. Select it and press Shift+F9
to toggle so that you see its field code. Copy the name of the _Ref bookmark
from the field code (e.g. “_Ref220319267â€).

On the Insert tab, click “Bookmarkâ€. To see the _Ref bookmarks in the dialog
box, you may need to click “Hidden bookmarks†twice. Paste (Ctrl+V) the
copied bookmark name into the name field and click the “Go to†button. Now
the _Ref bookmark to which the cross-reference points should be selected in
the document. Check the selection. Does the selection include two footnote
references?



--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
U

UtopiaSoon

I'm testing the macro on a little sample document with just two footnotes,
one cross referenced and one inserted, with the cross ref incorrectly still
pointing to footnote 1. I followed your instructions, and indeed after
selecting 'go to', 2 footnotes were highlighted, the first of which being the
one that the cross reference displayed. Then, I ran the macro again. This
time, it worked, and the two footnotes were highlighted in red! I closed
word, reopened it, and made a new document with a bad cross ref. Created and
ran the macro, it did NOT work. Did the 'go to' bookmark thing again, it
highlights 2 footnotes, ran the macro, it works again!

How is selecting and clicking 'go to' to highlight the bad footnotes making
the macro work for me? The next logical question: does going through this
'go to' bookmark thing affect all bad cross refs in the document such that
the macro will work, or only the ones I've selected and gone to via the
insert bookmark pane? Easy to test, and indeed, after 'going to' one pair of
bad footnotes, the macro works for the whole document.

Why is this occuring? Is there a simple modification to the macro possible
that would make it just work right away?
 
L

Lene Fredborg

I see. Since I had made all my experiments before I made the macro, I had
hidden bookmarks shown so I was not aware of the problem you experience.

You should be able to make the macro work right away if you insert the
following line of code before the “For each…†line:

ActiveDocument.Bookmarks.ShowHidden = True

The code makes the hidden bookmarks visible (turns on the hidden bookmarks
check box).


--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
U

UtopiaSoon

Alright, I've got everything working now. Thanks again for all your help
with this.

I've run this macro on a real document with many cites, and it highlighted a
single pair of footnotes. I checked all the cross refs, they all seem to
have the correct number. I deleted each cross ref referring to the flagged
footnotes, and redid each one, thinking this will get the _Ref only around
the one footnote, and will hopefully make the macro think things were okay.
I got rid of the red highlight, and ran the macro again. The two footnotes
were still highlighted.

Is the only answer that I've missed a cross ref so the bookmark is still
encompassing both footnotes? Then why is each cross ref I see refering to
either of the two highlighted-in-red footnotes correct? I'm curious, does
each cross ref to a single footnote create it's own bookmark, or do they
share one? If each one has it's own, shouldn't this macro be made to show us
the cross ref rather than the bad bookmark, which avoids searching the
document for possibly several cross refs, only one of which is offending?
I'm wondering if there is any other reason a pair of footnotes would be
highlighted by this macro, besides the possibility of a cross ref not
incremening upon a footnote insertion.
 
U

UtopiaSoon

Another comment, as I go through the list of _Refs in the insert bookmark
pane and select 'go to' for each one, I can find the _Ref that extends around
2 footnotes and that is causing the macro to highlight the pair of footnotes.
However, I cannot find anywhere in the document the cross ref that generated
the _Ref. I'm searching for cross refs by copying the _Ref# from the insert
bookmark pane, making all fields in the document display, and searching for
the _Ref#. Does Word sometimes not delete a bookmark (the _Ref) after a user
has deleted the corresponding cross ref??
 
L

Lene Fredborg

Note that the answer below was written before I read your latest post:

If you insert more cross-references to the same footnote, they should all
point to the same _Ref bookmark. That is at least what happened in all my
tests. As I wrote yesterday, the macro can be improved in many ways. It was
just my attempt to make something you could use as a starting point
(hopefully better than nothing). I did not have the time for a more complex
solution – and I found that you need to find the bad bookmark first. After
that, it would be possible – also via the macro – to find and mark any
cross-reference that point to the bad bookmark (not to be made by me now…).

The macro version below has been changed so that it shows the bookmark
name(s) of the erroneous bookmarks in the final message. You can use
Alt+PrintScreen to capture the dialog box and insert it in a document so you
have the bookmark names present if you wish. In your document, press Alt+ F9
to toggle field codes. You can now search for fields holding the problematic
_Ref bookmark names. This should help you find the cross-references that need
to be corrected.

Sub Footnotes_MarkProblemRefBookmarks()

Dim oBookmark As Bookmark
Dim nCount As Long
Dim strMsg As String

nCount = 0

'Create start of message text
strMsg = vbCr & vbCr & "Check cross-references with these bookmark
name(s):" & vbCr
ActiveDocument.Bookmarks.ShowHidden = True

For Each oBookmark In ActiveDocument.Bookmarks
With oBookmark
If Left(oBookmark.Name, 4) = "_Ref" Then
If .Range.Footnotes.Count > 1 Then
.Range.HighlightColorIndex = wdRed
nCount = nCount + 1
'Append bookmark name to msg
strMsg = strMsg & .Name & vbCr
End If
End If
End With
Next oBookmark

'Show msg incl. info about bookmark names to check
MsgBox nCount & " _Ref bookmarks that include more than one footnote
reference were found and marked by red highlight." & strMsg, vbOKOnly,
"Result of _Ref bookmark check"

End Sub

--------------
Comment to your last post: Word can leave in a document many bookmarks that
are no longer used. I remember I once checked a document that had been
revised by many people during af very long period of time. It included more
than 4000 bookmarks. As far as I remember, less than 100 of the bookmarks
were relevant.

If bookmarks are listed in the dialog box when using the new macro version
and if you do not find any cross-references that point to those bookmarks,
you can just delete the bookmarks.

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
U

UtopiaSoon

Lene,

I didn't mean to seem to imply that the macro you wrote earlier or the
information you gave wasn't helpful or good enough, since all together it
does, in combination with the results of looking through the list of _Refs
and finding where they point, allows me to fairly rapidly fix these bad cross
references. The improved version you give below will save even more time in
this process. In my last posts, I was trying to understand how bookmarks
work, and envisioning how an ideal solution might look for this problem.

I wonder if these issues, along with other issues you mention about
bookmarks at your site, will be addressed in future versions of Word.

Thanks again for your time, I learned a lot from this.
 
C

Chris D

I've been frustrated by this problem for years. Try editing a thesis
with hundreds of references and dozens of cross references. My only
solution is to highlight any cross references and fix them at the
absolute last step before finalizing my document. How many thousands
of Microsoft employees does it take to fix such problems? Sorry Utopia
that you had to waste so much time trying to find a (non-existent)
solution and messing around with macros...I just found this thread
after Googling for a fix myself...
 

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