EndNotes

  • Thread starter Thread starter DavidSherwood
  • Start date Start date
D

DavidSherwood

I would like to create EndNotes from a number list. The text already has
superscripts refering to these numbers. Is there a way to convert these to
EndNotes?
 
If the notes list is contained in a 2 column table saved as a document, then
the following macro will locate the superscripted number from the first
table column and replace it with an endnote reference containing the text
from the second column. The macro does not allow for multiple references to
the same endnote. Each number will be treated as a new end note.

Change the name of the document ("D:\My Documents\Word
Documents\EndNoteTable.doc") to reflect the path to your own table document.
http://www.gmayor.com/installing_macro.htm

Run the macro with the document to be annotated in view.
If you don't like the result, don't save the modified document!

Sub EndNotesFromList()
Dim oList As Document
Dim oDoc As Document
Dim oRng As Range
Dim oTable As Table
Dim oNum As Range
Dim oNote As Range
Set oDoc = ActiveDocument
Set oList = Documents.Open("D:\My Documents\Word
Documents\EndNoteTable.doc")
oDoc.Activate
Set oTable = oList.Tables(1)
For i = 1 To oTable.Rows.Count
Set oNum = oTable.Rows(i).Cells(1).Range
Set oNote = oTable.Rows(i).Cells(2).Range
oNum.End = oNum.End - 1
oNote.End = oNote.End - 1
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Font.Superscript = True
.MatchWildcards = True
Do While .Execute(oNum)
Set oRng = Selection.Range
oRng.Endnotes.Add oRng, , oNote.Text
oRng.Text = ""
Loop
End With
End With
Next i
End Sub
 
This almost worked. It doesn't handle 2 digit numbers. When it got to 10, it
repeated the first note and started picking random notes up to 24. But there
is only 17 notes.
 
My fault :( I only tested with single digit numbers and the two parts of the
superscripted double digit number are treated as separate number entries. If
you reverse the search starting at the largerst number, it should be OK.
Note that the numbers that you have in the document will not match the
numbers in the end notes if the numbers are not entered consecutively, but
the references should now be correct.

Sub EndNotesFromList()
Dim oList As Document
Dim oDoc As Document
Dim oRng As Range
Dim oTable As Table
Dim oNum As Range
Dim oNote As Range
Set oDoc = ActiveDocument
Set oList = Documents.Open("D:\My Documents\Word
Documents\EndNoteTable.doc")
oDoc.Activate
Set oTable = oList.Tables(1)
For i = oTable.Rows.Count To 1 Step -1
Set oNum = oTable.Rows(i).Cells(1).Range
Set oNote = oTable.Rows(i).Cells(2).Range
oNum.End = oNum.End - 1
oNote.End = oNote.End - 1
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Font.Superscript = True
.MatchWildcards = True
Do While .Execute(oNum)
Set oRng = Selection.Range
oRng.Endnotes.Add oRng, , oNote.Text
oRng.Text = ""
Loop
End With
End With
Next i
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Back
Top