Results 1 to 2 of 2
  1. #1
    Lounger
    Join Date
    Dec 2011
    Posts
    33
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Referencing endnotes in Word 2010

    Hi folks,

    Our client has insisted on using endnotes to create a bibliography at the end of a Word 2010 document. I never use Word's endnote feature and I'm a little baffled by the behavior I'm seeing. According to what I've read , if I want to refer to the same endnote after its initial use I should use the Cross Reference feature and insert the number for the endnote. I expected that the x-ref would, when clicked, take me to the end of the document to read the item in the bibliography. Instead it's taking me to the first place I referenced that item, so now a reader has to click twice just to see what's being referenced. I've attached a sample document illustrating it.

    This makes no sense to me. Is there a way to reference an endnote so that the reader goes directly to the bibliography?

    Thanks in advance,

    Beej
    Attached Files Attached Files

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Endnote cross-references only take you to the endnote reference, not to the actual endnote. The same applies to footnote references. None of these will take you to a Bibliography. To hyperlink directly to the endnote or footnote, a lot of work is required - hyperlinks need to be created wherever there's an endnote/footnote reference or cross-reference. The following macro does that, but I suggest you don't use it on a document that's still subject to editing. One advantage of this approach is that the links continue to work when the file is saved as a PDF.
    Code:
    Sub HyperlinkEndNotesFootNotes()
    Dim SBar As Boolean           ' Status Bar flag
    Dim TrkStatus As Boolean      ' Track Changes flag
    Dim Rng1 As Range, Rng2 As Range, StrRef As String, i As Long
    ' Store current Status Bar status, then switch on
    SBar = Application.DisplayStatusBar
    Application.DisplayStatusBar = True
    ' Store current Track Changes status, then switch off
    With ActiveDocument
      TrkStatus = .TrackRevisions
      .TrackRevisions = False
    End With
    ' Turn Off Screen Updating
    Application.ScreenUpdating = False
    With ActiveDocument
    
     'Process all endnotes
      For i = 1 To .Endnotes.Count
        'Update the statusbar
        StatusBar = "Processing Endnote " & i
        'Define two ranges: one to the endnote reference the other to the endnote content
        Set Rng1 = .Endnotes(i).Reference
        Set Rng2 = .Endnotes(i).Range.Paragraphs.First.Range
        With Rng1
          'Format the endnote reference as hidden text
          .Font.Hidden = True
          'Insert a number before the endnote reference and bookmark it
          .Collapse wdCollapseStart
          'To get the actual reference text, we need to cross-reference it!
          .InsertCrossReference wdRefTypeEndnote, wdEndnoteNumber, i, False, False
          .End = .End + 1
          StrRef = .Fields(1).Result
          .Fields(1).Delete
          .Text = StrRef
          .Style = "Endnote Reference"
          .Bookmarks.Add Name:="_ERef" & i, Range:=Rng1
        End With
        'Insert a number before the endnote content and bookmark it
        With Rng2
          'Format the endnote reference as hidden text
          With .Words.First
            If .Characters.Last Like "[ " & vbTab & "]" Then .End = .End - 1
            .Font.Hidden = True
          End With
          'Insert a number before the endnote reference and bookmark it
          .Collapse wdCollapseStart
          .Text = StrRef
          .Style = " Endnote Reference"
          .Bookmarks.Add Name:="_ENum" & i, Range:=Rng2
        End With
        'Insert hyperlinks between the endnote references
        .Hyperlinks.Add Anchor:=Rng1, SubAddress:="_ENum" & i
        .Hyperlinks.Add Anchor:=Rng2, SubAddress:="_ERef" & i
        'Restore the Rng1 endnote reference bookmark
        .Bookmarks.Add Name:="_ERef" & i, Range:=Rng1
      Next
        'Give Word a chance to do its housekeeping
        DoEvents
      'Process all footnotes
      For i = 1 To .Footnotes.Count
        'Update the statusbar
        StatusBar = "Processing Footnote " & i
        'Define two ranges: one to the footnote reference the other to the footnote content
        Set Rng1 = .Footnotes(i).Reference
        Set Rng2 = .Footnotes(i).Range.Paragraphs.First.Range
        With Rng1
          'Format the footnote reference as hidden text
          .Font.Hidden = True
          'Insert a number before the footnote reference and bookmark it
          .Collapse wdCollapseStart
          'To get the actual reference text, we need to cross-reference it!
          .InsertCrossReference wdRefTypeFootnote, wdFootnoteNumber, i, False, False
          .End = .End + 1
          StrRef = .Fields(1).Result
          .Fields(1).Delete
          .Text = StrRef
          .Text = i
          .Style = "Footnote Reference"
          .Bookmarks.Add Name:="_FRef" & i, Range:=Rng1
        End With
        'Insert a number before the footnote content and bookmark it
        With Rng2
          'Format the footnote reference as hidden text
          With .Words.First
            If .Characters.Last Like "[ " & vbTab & "]" Then .End = .End - 1
            .Font.Hidden = True
          End With
          'Insert a number before the footnote reference and bookmark it
          .Collapse wdCollapseStart
          .Text = StrRef
          .Style = " Footnote Reference"
          .Bookmarks.Add Name:="_FNum" & i, Range:=Rng2
        End With
        'Insert hyperlinks between the footnote references
        .Hyperlinks.Add Anchor:=Rng1, SubAddress:="_FNum" & i
        .Hyperlinks.Add Anchor:=Rng2, SubAddress:="_FRef" & i
        'Restore the Rng1 footnote reference bookmark
        .Bookmarks.Add Name:="_FRef" & i, Range:=Rng1
      Next
     'Update the statusbar
      StatusBar = "Finished Processing " & .Endnotes.Count & " Endnotes" & .Footnotes.Count & " Footnotes"
    End With
    Call HLnkNoteRefs
    Set Rng1 = Nothing: Set Rng2 = Nothing
    ' Restore original Status Bar status
    Application.DisplayStatusBar = SBar
    ' Restore original Track Changes status
    ActiveDocument.TrackRevisions = TrkStatus
    ' Restore Screen Updating
    Application.ScreenUpdating = True
    End Sub
    
    Sub HLnkNoteRefs()
    Dim Fld As Field, StrTgt As String, Rng As Range, StrRef As String
    ActiveDocument.ActiveWindow.View.ShowFieldCodes = True
    For Each Fld In ActiveDocument.Fields
      With Fld
        If .Type = wdFieldNoteRef Then
          StrTgt = ActiveDocument.Bookmarks(Split(Trim(.Code), " ")(1)).Range.Characters.First.Hyperlinks(1).SubAddress
          StrRef = .Result
          Set Rng = .Code
          With Rng
            While .Fields.Count = 0
              .Start = .Start - 1
            Wend
            .Collapse wdCollapseStart
            .Hyperlinks.Add Anchor:=Rng, SubAddress:=StrTgt, TextToDisplay:=StrRef
            .End = .End + 1
            .Hyperlinks(1).Range.Font.Superscript = True
          End With
          .Result.Font.Hidden = True
        End If
      End With
    Next
    ActiveDocument.ActiveWindow.View.ShowFieldCodes = False
    End Sub
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. The Following User Says Thank You to macropod For This Useful Post:

    ItsjustBeej (2016-02-01)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •