PDA

View Full Version : [SOLVED:] Convert footnotes to inline citations in Word while retaining footnote number as text



toddntucker
09-30-2013, 01:52 PM
I am trying to convert footnotes to inline citations.

There are various macros on the web that give some guidance, but I have not been able to find one that allows the footnote number to be retained and presented as string.

The code below returns [Note: Note text]. What I would like instead is [Note number: note text].


Sub foot2inline()
Dim oFeets As Footnotes
Dim oFoot As Footnote
Dim oRange As Range
Dim szFootNoteText As String

' Grabs the collection of FootNotes
Set oFeets = Word.ActiveDocument.Footnotes

' Iterates through each footnote
For Each oFoot In oFeets



szFootNoteText = oFoot.Range.Text

'Start search from beginning of document
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting

With Selection.Find
.Text = "^f" ' Looks for all footnotes
.Forward = True
.Wrap = wdFindStop
End With

Selection.Find.Execute
' Delete the footnote
oFoot.Delete

'Insert the footnote text
'Here you do whatever format tickles your fancy
Selection.Text = " [Note: " + szFootNoteText + "] "

'CHANGE COLOR HERE. Color code is below.
Selection.Font.Color = 6299648

'Disables undo to save memory on very large documents.
ActiveDocument.UndoClear
Next
End Sub

gmaxey
09-30-2013, 03:14 PM
Maybe:


Sub foot2inline()
Dim oFNs As Footnotes
Dim oFN As Footnote
Dim oRng As Range
Dim strFNText As String
Dim lngIndex As Long

Set oFNs = Word.ActiveDocument.Footnotes
For Each oFN In oFNs
strFNText = oFN.Range.Text
lngIndex = lngIndex + 1
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "^f" ' Looks for all footnotes
.Forward = True
.Wrap = wdFindStop
If .Execute Then
oFN.Delete
With oRng
.Text = " [Note " & lngIndex & ": " & strFNText & "]"
.Font.Color = 6299648
End With
End If
End With
'Disables undo to save memory on very large documents.
'ActiveDocument.UndoClear
Next
End Sub

toddntucker
09-30-2013, 03:38 PM
That worked great. Thanks!

macropod
09-30-2013, 11:56 PM
Cross-posted (and answered) at: http://answers.microsoft.com/en-us/office/forum/office_2010-word/convert-footnote-to-inline-citation/6e2cc6cc-add0-4af9-abc0-1c6e14e9c7ac
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184

toddntucker
10-01-2013, 05:38 AM
My apologies. Thanks for the tip.