Save as pdf breaks endnote links

Hi,

When I save my .doc or .docx as pdf, the endnote links doesn't work in the pdf document. 

I've seen a lot of people having problem with TOC or other cross references. All of these seems to work fine for me. The only thing not working is the endnotes.

Any suggestions on how to solve this?

Best regards

David

Answer
Answer

When a document is saved in PDF format, endnote & footnote references cease to act as hyperlinks.

The following macro replicates the endnote & footnote references (which become hidden text) with bookmarked hyperlinks. The second macro (KillEndNoteFootNoteHyperLinks) reverses the process.

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
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 KillEndNoteFootNoteHyperLinks()
Dim SBar As Boolean           ' Status Bar flag
Dim TrkStatus As Boolean      ' Track Changes flag
Dim Rng1 As Range, Rng2 As Range, 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

  'Delete endnote/footnote hyperlinks from the MainStory
  For i = .Hyperlinks.Count To 1 Step -1
    With .Hyperlinks(i)
      StatusBar = "Processing Hyperlink " & i
      If .SubAddress Like "_ENum*" Then
        .Range.Delete
      ElseIf .SubAddress Like "_FNum*" Then
        .Range.Delete
      End If
    End With
  Next i

  'Delete endnote hyperlinks from the EndnotesStory
  If .Endnotes.Count > 0 Then
    With .StoryRanges(wdEndnotesStory)
      For i = .Hyperlinks.Count To 1 Step -1
        StatusBar = "Processing Endnote Hyperlink " & i
        With .Hyperlinks(i)
          If .SubAddress Like "_ERef*" Then .Range.Delete
        End With
      Next i
    End With
  End If

  'Delete footnote hyperlinks from the FootnotesStory
  If .Footnotes.Count > 0 Then
    With .StoryRanges(wdFootnotesStory)
      For i = .Hyperlinks.Count To 1 Step -1
        StatusBar = "Processing Footnote Hyperlink " & i
        With .Hyperlinks(i)
          If .SubAddress Like "_FRef*" Then .Range.Delete
        End With
      Next i
    End With
  End If

  '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
    'Format the endnote reference as visible text
    Rng1.Font.Hidden = False
    Rng2.Words.First.Font.Hidden = False
  Next

  '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
    'Format the footnote reference as visible text
    Rng1.Font.Hidden = False
    Rng2.Words.First.Font.Hidden = False
  Next

  'Update the statusbar
  StatusBar = "Finished Processing " & .Endnotes.Count & " Endnotes" & .Footnotes.Count & " Footnotes"
End With
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

Cheers
Paul Edstein
(Fmr MS MVP - Word)

3 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Answer
Answer

Hello David,

Thank you for posting your query in Microsoft Office Community.

Unfortunately, link to Endnote is not preserved when you save a Word document in PDF format.

If you think this feature is important and want Microsoft to include it, you may provide your feedback through the following link.
http://office.microsoft.com/en-US/suggestions.aspx?origin=FX101741961&CTT=114

If you have any other queries related to Office products, feel free to reply and I'll be happy to further assist you.

Thank you.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated March 16, 2023 Views 2,161 Applies to: