VBA & Macro Problems

Preserve Footnote Formatting When Converting Text with Word VBA

Maira MehtabMaira Mehtab Nov 27, 2026 868 views

Question details

Convert Word footnotes to inline text without losing formatting such as italics and underlining.

Preserve Footnote Formatting When Converting Text with Word VBA
Product
Microsoft Word VBA
Device & OS
not provided
Scenario
A macro prepares document text for a website by moving footnote content into the main text.
Observed behavior
Inserting only the footnote text loses character formatting, and processing thousands of footnotes can make Word appear unresponsive.
Before you start

Open the document in desktop Word and test the macro on a small copy containing formatted footnotes. The example replaces each footnote reference with bracketed inline text; adjust the markers if your website needs a different format.

Solution 1Recommended

Insert formatted footnote text with a Word VBA macro

Use FormattedText to preserve character formatting and process footnotes in reverse order while screen updating is disabled.

Assigning Range.Text copies plain text. Assigning Range.FormattedText copies the formatted range instead. The example removes a trailing paragraph mark if present so it does not introduce an extra paragraph into the main text.

The macro changes footnotes into bracketed Word text, not HTML. Check the result and your website export process to confirm that the formatting carries through.

1
Open the VBA editor

In desktop Word, open the target document and press Alt+F11 to open the VBA editor. Select Insert > Module.

2
Add the conversion macro

Paste this code into the module: Sub FootnotesToInlineFormatted() Dim doc As Document Dim fn As Footnote Dim noteText As Range Dim insertion As Range Dim i As Long Dim previousScreenUpdating As Boolean Dim errorMessage As String Set doc = ActiveDocument previousScreenUpdating = Application.ScreenUpdating On Error GoTo CleanFail Application.ScreenUpdating = False For i = doc.Footnotes.Count To 1 Step -1 Set fn = doc.Footnotes(i) Set noteText = fn.Range.Duplicate If noteText.End > noteText.Start Then If noteText.Characters.Last.Text = vbCr Then noteText.End = noteText.End - 1 End If End If Set insertion = fn.Reference.Duplicate insertion.Collapse Direction:=wdCollapseEnd insertion.InsertAfter " [" insertion.Collapse Direction:=wdCollapseEnd If noteText.End > noteText.Start Then insertion.FormattedText = noteText.FormattedText insertion.Collapse Direction:=wdCollapseEnd End If insertion.InsertAfter "]" fn.Delete Next i CleanExit: Application.ScreenUpdating = previousScreenUpdating If Len(errorMessage) > 0 Then MsgBox errorMessage, vbExclamation Exit Sub CleanFail: errorMessage = "Conversion stopped: " & Err.Description Resume CleanExit End Sub

3
Run and inspect the result

Place the cursor inside the macro and press F5. Return to the document and check that the bracketed inline text retains the expected italics and underlines and that the footnote references are gone.

Insert formatted footnote text with a Word VBA macro
Allow time for large documents: Turning off ScreenUpdating can improve performance, but thousands of footnotes may still take time. If an error stops the macro, the document may be only partly converted; inspect it before continuing.
Free Microsoft Office alternative

Edit Word documents with WPS Writer

WPS Writer is a free, lightweight alternative for editing documents in a familiar interface. Its Microsoft Word format compatibility makes it easy to move existing files into WPS Office, although it does not fix Microsoft Word VBA macro behavior.

Review formatted footnote content in a word processorOpen and edit Microsoft Word DOC and DOCX filesUse a familiar interface for everyday document editingMove existing documents to a free, lightweight office suite
QA img-9

Frequently Asked Questions

Why does my macro remove italics and underlining from footnotes?

Assigning a footnote range's Text copies plain text. Assign its FormattedText to the insertion range instead to carry over character formatting.

Why should the macro process footnotes from last to first?

Deleting a footnote changes the collection. Starting with ActiveDocument.Footnotes.Count and counting down avoids skipping footnotes as the collection changes.

What can I do if Word appears to freeze on a large document?

Set Application.ScreenUpdating to False before the loop and restore its previous value afterward, including in the error handler. The macro can still take time when a document has thousands of footnotes.

Does this macro create formatted HTML for my website?

No. It creates formatted inline text in the Word document. Use your website's import or export process and verify that italics and underlines are preserved there.