Skip to content

Instantly share code, notes, and snippets.

@ZCG-coder
Created September 17, 2025 08:21
Show Gist options
  • Select an option

  • Save ZCG-coder/a3d3ec9c8faddc2fe8b5f910e7d7da5c to your computer and use it in GitHub Desktop.

Select an option

Save ZCG-coder/a3d3ec9c8faddc2fe8b5f910e7d7da5c to your computer and use it in GitHub Desktop.
Convert footnotes to a references field
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "ThisDocument"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Sub FootnotesToReferenceField()
Dim refList As String
Dim i As Integer
Dim fn As Footnote
refList = ""
For i = 1 To ActiveDocument.Footnotes.Count
Set fn = ActiveDocument.Footnotes(i)
refList = refList & i & ". " & Trim(fn.Range.Text) & vbCrLf
Next i
SetCustomProperty "FootnoteList", refList
End Sub
Sub SetCustomProperty(propName As String, propValue As String)
Dim props As DocumentProperties
Dim p As DocumentProperty
Set props = ActiveDocument.CustomDocumentProperties
On Error Resume Next
Set p = props(propName)
If Err.Number <> 0 Then
Err.Clear
props.Add Name:=propName, LinkToContent:=False, Type:=msoPropertyTypeString, Value:=propValue
Else
p.Value = propValue
End If
On Error GoTo 0
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment