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
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