UW Law School KnowledgeBase

Endnotes to plain text Word

Quick guide on how to set up a Macro that will convert a Word document's endnotes to plain text, preserve the number placement in the document, and not change the formatting.

1. Open the document to be changed and press ALT-F8 to open the Visual Basic editor window. Type a name for your Macro. (The name can not contain spaces or certain
characters, recommend "endnotetotext") and press "Create".

Copy the following script into the editor:

Application.ScreenUpdating = False
Dim nRng As Range, eNote As Endnote, nRef As String
With ActiveDocument
For Each eNote In .Endnotes
With eNote
With .Reference.Characters.First
.Collapse wdCollapseStart
.InsertCrossReference wdRefTypeEndnote, wdEndnoteNumberFormatted, eNote.Index
nRef = .Characters.First.Fields(1).Result
.Characters.First.Fields(1).Unlink
End With
.Range.Cut
End With
If .Range.EndnoteOptions.Location = wdEndOfSection Then
Set nRng = eNote.Range.Sections.First.Range
Else
Set nRng = .Range
End If
With nRng
.Collapse wdCollapseEnd
.End = .End - 1
If .Characters.Last <> Chr(12) Then .InsertAfter vbCr
.InsertAfter nRef & " "
With .Paragraphs.Last.Range
.Style = "Endnote Text"
.Words.First.Style = "Endnote Reference"
End With
.Collapse wdCollapseEnd
.Paste
If .Characters.Last = Chr(12) Then .InsertAfter vbCr
End With
Next
For Each eNote In .Endnotes
eNote.Delete
Next
End With
Set nRng = Nothing
Application.ScreenUpdating = True

(Note: the script above does not include the beginning and end of the
macro, < Sub endnotetotext() > . Just paste the text into
the middle of the text block in the macro editor. The picture below has the entire macro text pictured)

4. Save and then Run the macro. It may take a moment or two to run depending on the document length. (The "Play" button highlighed below is how you run the macro.)

In the future, to run the macro on other documents, click on the View tab, then Macros and then run the "endnotetotext" macro.