This macro turns footnotes you have written inline in the body text into real Word footnotes at the right positions. The footnote numbers are assigned and referenced automatically, and each is linked within Word so the reader can jump back and forth.

Mark the start of a footnote with {FN: and the end with } - both used in the continuous text without quotation marks.

Example:

Lorum voluptua.{FN:ICC-01/09-02/11; emphasis} At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.{FN:ICC-01/09-02/11; emphasis}

Tip

There should not be a space between the footnote and the referenced word or sentence, otherwise this space will remain with the later footnote number and the referenced sentence or word.

Format templates used

The standard Word styles are used. For deviating changes in the presentation of the footnote itself, this is the format template “Footnote text”. For an individual adaptation of the footnote number, the format template “Footnote characters” in the letterhead must be adapted.

Code example

Sub AutoOpen() 

Dim OpenStrg As String 
Dim CloseStrg As String 
Dim myRange As Range 
Dim StartPos As Long 
Dim EndPos As Long 

OpenStrg = "{FN:" 
CloseStrg = "}" 

StartPos = InStr(1, ActiveDocument.Range.Text, OpenStrg, vbTextCompare) - 1 

Do Until StartPos = -1 
	Set myRange = ActiveDocument.Range 
	EndPos = InStr(StartPos, ActiveDocument.Range.Text, CloseStrg, vbTextCompare)
	myRange.SetRange Start:=StartPos, End:=EndPos 

	ActiveDocument.Footnotes.Add Range:=myRange, Text:=Mid(myRange.Text, Len(OpenStrg) + 1 Len(myRange.Text) - Len(CloseStrg) - Len(OpenStrg)) 

	myRange.Text = "" 
	StartPos = InStr(StartPos, ActiveDocument.Range.Text, OpenStrg,vbTextCompare) - 1 

Loop 
	
End Sub

Note: There are restrictions in the functioning of the macro if the document contains function fields (e.g. tables of contents) or clickable URLs (“::url”). An alternative to this is shown below.

Code example for documents with function fields and/or clickable URLs

If you want your document to contain function fields such as a table of contents or clickable links (“::url”) in addition to footnotes, it is necessary to use an appropriately adapted macro. In the following we provide you with a sample code:

Sub AutoOpen()

Dim OpenStrg As String
Dim CloseStrg As String
Dim myRange As Range
Dim myPara As Paragraph
Dim StartPos As Long
Dim EndPos As Long

OpenStrg = "{FN:"
CloseStrg = "}"

For Each myPara In ActiveDocument.Paragraphs
StartPos = InStr(1, myPara.Range.Text, OpenStrg, vbTextCompare) - 1
Do Until StartPos = -1
	Set myRange = myPara.Range
	EndPos = InStr(StartPos, myPara.Range, CloseStrg, vbTextCompare)
	myRange.SetRange Start:=myRange.Start + StartPos, End:=myRange.Start + EndPos
	ActiveDocument.Footnotes.Add Range:=myRange, Text:=Mid(myRange.Text, Len(OpenStrg) + 1, Len(myRange.Text) - Len(CloseStrg) - Len(OpenStrg))
	myRange.Text = ""
	StartPos = InStr(StartPos, myPara.Range, OpenStrg, vbTextCompare) - 1
Loop

Next

End Sub

Note: Since the macro searches each paragraph individually and finds and creates footnotes, it is important that there are always only footnotes OR function fields or hyperlinks (“::url”) in a paragraph. If this is not the case, display problems may occur. In addition, care must be taken that the marking of a footnote “{FN:…} is always within a paragraph and not across several paragraphs.

Code to prepare footnotes for the import

If you want to import a text that already contains footnotes and want to display them as such again in the export, you can also use a macro for this. The following macro converts your footnotes into the format described above (“{FN:…}”). This way you can prepare extensive texts with footnotes appropriately.

Sub Re_FN_UPdated_3()
    Dim FtNt As Footnote
    Dim FNTxt
    
    For Each FtNt In ActiveDocument.Footnotes
        With FtNt.Reference
        .Font.Superscript = False
            FNTxt = FtNt.Range.Text
            If Asc(Left(FNTxt, 1)) = "2" Or Asc(Left(FNTxt, 1)) = "9" Then
                FNTxt = Right(FNTxt, Len(FNTxt) - 1)
                If Asc(Left(FNTxt, 1)) = "9" Then
                    FNTxt = Right(FNTxt, Len(FNTxt) - 1)
                    .Text = "{FN:" & FNTxt & "}"
            
                Else
                    .Text = "{FN:" & FNTxt & "}"
                End If
            Else
                .Text = "{FN:" & FtNt.Range.Text & "}"
            End If
            
        End With
    Next

End Sub

To convert the expressions back to footnotes in the export, you can use the first macro again!

Run the macro: see How to insert and run a Word macro.