Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-12-2014, 04:48 PM
rekent rekent is offline VBA code to read number of footnote and enter in text Mac OS X VBA code to read number of footnote and enter in text Office for Mac 2011
Novice
VBA code to read number of footnote and enter in text
 
Join Date: May 2014
Posts: 2
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
  #2  
Old 05-13-2014, 02:05 AM
macropod's Avatar
macropod macropod is offline VBA code to read number of footnote and enter in text Windows 7 32bit VBA code to read number of footnote and enter in text Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,793
macropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud ofmacropod has much to be proud of
Default

Try:
Code:
Sub foot2inline()
Dim i As Long
Dim Rng As Range
Dim NtRng As Range
Dim FtNtRef As String
With ActiveDocument
  For i = .Footnotes.Count To 1 Step -1
    With .Footnotes(i)
      Set Rng = .Reference
      Set NtRng = .Reference
      FtNtRef = .Reference.FormattedText
      Rng.Collapse wdCollapseStart
      Rng.FormattedText = .Range.FormattedText
      With Rng
        .InsertAfter "]"
        .InsertBefore " "
        .Collapse wdCollapseStart
        .InsertCrossReference wdRefTypeFootnote, wdFootnoteNumberFormatted, i
        .InsertBefore "["
        .Start = .Start - 1
        .End = NtRng.End
        .Fields(1).Unlink
        .Font.Color = 6299648
      End With
      .Delete
    End With
  Next
End With
End Sub
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 05-13-2014, 06:53 AM
rekent rekent is offline VBA code to read number of footnote and enter in text Mac OS X VBA code to read number of footnote and enter in text Office for Mac 2011
Novice
VBA code to read number of footnote and enter in text
 
Join Date: May 2014
Posts: 2
rekent is on a distinguished road
Default

Work perfect! Thanks!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA code to read number of footnote and enter in text VBA code for Microsoft Word macro select text and insert footnote ndnd Word VBA 10 01-06-2015 01:47 PM
number in footnote line ScientificKat Word 2 07-09-2012 06:25 AM
VBA code to read number of footnote and enter in text Enter + Alt + Enter is not working inside the text box! why???? Jamal NUMAN Word 3 04-17-2011 05:35 PM
Footnote text is not aligned with the corresponding number Patrick1988 Word 0 08-28-2010 09:33 PM
VBA code to read number of footnote and enter in text Enter Number on any sheet one time only. paulrm906 Excel 1 04-28-2006 07:35 AM


All times are GMT -7. The time now is 08:05 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2020 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft