Footnotes
A footnote explains, comments on or gives the source of a passage without interrupting the text. TXTextControl has supported footnotes since version 32.0: a small number, the reference mark, stands in the text, and the note itself appears at the bottom of the page, behind a footnote mark with the same number.
Visual Basic 6 code inserts, edits, numbers, finds and deletes footnotes through a handful of TXTextControl members. The samples come from the menus of the TXWords sample program, which A Word Processor describes.
How Footnotes Work
The texts of all footnotes on a page are shown in the footnote section at the bottom of the page. It is a text part of its own: the user types and formats in it as in the main text, including tables and images. Footnotes can't be inserted in headers, footers or text frames.

All footnotes are numbered from the beginning to the end of the document. When a footnote is inserted in front of existing ones, the numbers of all following footnotes are increased and updated automatically.
The footnote members don't use these numbers. Each footnote has a unique identifier, a Long value that TX Text Control creates and manages, and every footnote member takes this identifier as its parameter. You get it from the method that inserts the footnote, from the events described below or by enumerating the footnotes of the document.
Footnotes are saved in the TX Text Control format (.tx), in RTF and in the Microsoft Word formats DOC and DOCX. Working with Files describes the formats.
Insert a Footnote
The FootnoteInsert method adds a footnote at the text input position, the place of the caret. The first parameter is the text of the footnote, which can be an empty string. The second parameter decides where the text input position goes: with True, it moves to the footnote section, behind the footnote mark, so that the user can type the text.

The Insert > Footnotes > Insert menu item of TXWords inserts an empty footnote and lets the user type its text:
Private Sub mnuInsert_Footnotes_Insert_Click()
TXTextControl1.FootnoteInsert "", True
End Sub
When your code supplies the text, it can keep the text input position in the main text and store the identifier that the method returns:
Dim FootnoteId As Long
FootnoteId = TXTextControl1.FootnoteInsert("Source: Annual Report 2025.", False)
If FootnoteId = 0 Then
MsgBox "The footnote could not be inserted."
End If
The code works as follows:
FootnoteInsertinserts the reference mark at the text input position and the footnote with the given text at the bottom of the page.- False leaves the text input position where it was.
- The return value is the identifier of the new footnote, or 0 when an error occurred or the footnote couldn't be inserted, for instance because the text input position is in a header, a footer or a text frame.
Track the Footnote at the Input Position
To offer commands such as Edit and Delete only when they make sense, an application needs to know whether the text input position is at a reference mark or in the footnote section. Events tell it:
- FootnoteReferenceMarkEntered and FootnoteReferenceMarkLeft occur when the text input position moves to or away from a reference mark. Both pass the identifier of the footnote.
- FootnoteSectionActivated and FootnoteSectionDeactivated occur when the footnote section of a page gets or loses the text input position.
- FootnoteCreated and FootnoteDeleted occur when a footnote has been created or deleted, with its identifier.
TXWords keeps the result of these events in two form-level variables:
Dim CurrentFootnoteID As Long
Dim IsInFootnoteSection As Boolean
Private Sub TXTextControl1_FootnoteCreated(ByVal FootnoteId As Long)
CurrentFootnoteID = FootnoteId
End Sub
Private Sub TXTextControl1_FootnoteDeleted(ByVal FootnoteId As Long)
If CurrentFootnoteID = FootnoteId Then CurrentFootnoteID = 0
End Sub
Private Sub TXTextControl1_FootnoteReferenceMarkEntered(ByVal FootnoteId As Long)
CurrentFootnoteID = FootnoteId
End Sub
Private Sub TXTextControl1_FootnoteReferenceMarkLeft(ByVal FootnoteId As Long)
CurrentFootnoteID = 0
End Sub
Private Sub TXTextControl1_FootnoteSectionActivated()
IsInFootnoteSection = True
End Sub
Private Sub TXTextControl1_FootnoteSectionDeactivated()
IsInFootnoteSection = False
End Sub
When the user opens the Footnotes submenu, TXWords enables its items from these variables and from IsInHeaderFooter, which its HeaderFooterActivated and HeaderFooterDeactivated handlers set:
Private Sub mnuInsert_Footnotes_Click()
mnuInsert_Footnotes_Insert.Enabled = Not IsInFootnoteSection And _
Not IsInHeaderFooter And (CurrentFootnoteID = 0)
mnuInsert_Footnotes_Delete.Enabled = Not IsInFootnoteSection And _
Not IsInHeaderFooter And (CurrentFootnoteID <> 0)
mnuInsert_Footnotes_Edit.Enabled = Not IsInFootnoteSection And _
Not IsInHeaderFooter And (CurrentFootnoteID <> 0)
End Sub
Insert is available only outside a reference mark, and Edit and Delete only at one; none of them is available in a header, a footer or the footnote section.
TXWords also uses IsInFootnoteSection when the user inserts an image, an OLE object, a text frame or a signature field: in the footnote section it inserts them as characters, with ImageInsertAsChar, ObjectInsertAsChar or TextFrameInsertAsChar, and elsewhere with ImageInsert, ObjectInsert or TextFrameInsert.
Edit, Find and Delete a Footnote
Three methods take the identifier of a footnote and return True when they succeed:
- FootnoteEdit moves the text input position to the end of the footnote's text in the footnote section, so that the user can edit or format it.
- FootnoteGoto moves the text input position to the reference mark and scrolls the text so that the reference mark is at the top of the visible text.
- FootnoteDelete removes the footnote from the document.
The Edit and Delete items of the TXWords Footnotes menu call them with the identifier of the footnote at the text input position:
Private Sub mnuInsert_Footnotes_Edit_Click()
If CurrentFootnoteID <> 0 Then TXTextControl1.FootnoteEdit CurrentFootnoteID
End Sub
Private Sub mnuInsert_Footnotes_Delete_Click()
If CurrentFootnoteID <> 0 Then TXTextControl1.FootnoteDelete CurrentFootnoteID
End Sub
Set the Number Format and Start Number
The FootnoteNumberFormat property sets how all footnotes of the document are numbered:
| Value | Numbering |
|---|---|
| 3 | Arabic numbers: 1, 2, 3 |
| 4 | Small letters: a, b, c |
| 5 | Capital letters: A, B, C |
| 6 | Roman numbers: I, II, III |
| 7 | Small Roman numbers: i, ii, iii |
FootnoteStartNumber sets the number of the first footnote. The following code numbers the footnotes with small letters and gives the first footnote the number 5:
TXTextControl1.FootnoteNumberFormat = 4
TXTextControl1.FootnoteStartNumber = 5
TXWords offers the five formats in the Insert > Footnotes > Number Format submenu. The items form a control array whose Index values are the values of FootnoteNumberFormat, 3 to 7, so one handler serves all of them:
Private Sub mnuInsert_Footnotes_NumberFormat_Symbols_Click(Index As Integer)
If mnuInsert_Footnotes_NumberFormat_Symbols(Index).Checked Then Exit Sub
TXTextControl1.FootnoteNumberFormat = Index
End Sub
When the submenu opens, TXWords checks the item mnuInsert_Footnotes_NumberFormat_Symbols(TXTextControl1.FootnoteNumberFormat), the one of the current format.
Highlight Footnote Numbers
FootnoteHighlightMode highlights the reference marks and the footnote marks, which gives the user an overview of the footnotes:
| Value | Constant | Highlighted |
|---|---|---|
| 1 | txNever | No footnote number. This is the default. |
| 2 | txActivated | The footnote number that contains the text input position. |
| 3 | txAlways | All footnote numbers. |
In TXWords, View > Highlight Footnotes has the items Always, Current and Never:
Private Sub mnuView_HighlightFootnotes_Always_Click()
TXTextControl1.FootnoteHighlightMode = txAlways
End Sub
Private Sub mnuView_HighlightFootnotes_Current_Click()
TXTextControl1.FootnoteHighlightMode = txActivated
End Sub
Private Sub mnuView_HighlightFootnotes_Never_Click()
TXTextControl1.FootnoteHighlightMode = txNever
End Sub
List All Footnotes
FootnoteNext returns the identifier of the footnote that follows a given one; with 0 it returns the first footnote, and after the last one it returns 0. A loop over FootnoteNext therefore visits every footnote of the document. The following code prints the name and the position of the reference mark of each footnote to the Immediate window:
Dim Id As Long
Id = TXTextControl1.FootnoteNext(0)
Do While Id <> 0
Debug.Print "Footnote " & Id & ": name '" & _
TXTextControl1.FootnoteName(Id) & "', characters " & _
TXTextControl1.FootnoteReferenceMarkStart(Id) & " to " & _
TXTextControl1.FootnoteReferenceMarkEnd(Id)
Id = TXTextControl1.FootnoteNext(Id)
Loop
The code works as follows:
- FootnoteName returns the name of the footnote, or an empty string when it has none. Your code sets the name to recognize a footnote later, for instance
TXTextControl1.FootnoteName(FootnoteId) = "source-1". - FootnoteReferenceMarkStart and FootnoteReferenceMarkEnd return the one-based indexes of the first and the last character of the reference mark in the text.
Key Members
| Member | Description |
|---|---|
| FootnoteInsert | Inserts a footnote at the text input position and returns its identifier. |
| FootnoteEdit | Moves the text input position to the end of a footnote's text. |
| FootnoteGoto | Moves the text input position to a footnote's reference mark and scrolls to it. |
| FootnoteDelete | Removes a footnote. |
| FootnoteNext | Returns the next footnote, to enumerate all footnotes. |
| FootnoteNumberFormat, FootnoteStartNumber | Set the number format and the number of the first footnote. |
| FootnoteHighlightMode | Highlights no, the current or all footnote numbers. |
| FootnoteReferenceMarkEntered, FootnoteReferenceMarkLeft | Occur when the text input position enters or leaves a reference mark. |
| FootnoteSectionActivated, FootnoteSectionDeactivated | Occur when the footnote section gets or loses the text input position. |
The programming category Using Footnotes lists all members for footnotes.