In my Word documents, I frequently have text like "See above, footnote 3." I'd like to replace the 3 with an actual cross-reference to footnote 3, so that it will be updated if the footnote numbering changes. How can I make a macro to automatically insert the cross-reference?
You can use the InsertCrossReference
member of the Selection
object:
Sub MkXref()
Selection.InsertCrossReference wdRefTypeFootnote, wdFootnoteNumber, Selection.Text, True
End Sub
To use this macro, assign it to a keyboard shortcut, put the cursor in or before the number you want to cross-reference, and press the assigned shortcut.
In some academic works, footnote 1 is attached to the author's name and is not numbered. This sets the numbering off: the note that appears as "footnote 1" is actually footnote 2 by Word's reckoning. To correct for this, you can do arithmetic on Section.Text
:
Sub MkXref()
Selection.InsertCrossReference wdRefTypeFootnote, wdFootnoteNumber, (Selection.Text + 1), True
End Sub
Note that there is no error-handling here.