View Single Post
 
Old 05-12-2014, 04:48 PM
rekent rekent is offline Mac OS X Office for Mac 2011
Novice
 
Join Date: May 2014
Posts: 22
rekent is on a distinguished road
Default VBA code to read number of footnote and enter in text

I found the following code that will take my footnotes from a Word document and put them inline inside brackets. They are prefaced with "Note:" but I would instead like them to maintain their footnote number. So instead of the current [Note: footnote text here] I want [1. footnote text here] where the number corresponds to the former number of the footnote. Since each footnote can be individually selected, is it possible to keep the numbers like this?

Code:
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
Reply With Quote