![]() |
#1
|
|||
|
|||
![]() 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 |
#2
|
||||
|
||||
![]()
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 [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
Work perfect! Thanks!
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
ndnd | Word VBA | 10 | 01-06-2015 01:47 PM |
number in footnote line | ScientificKat | Word | 2 | 07-09-2012 06:25 AM |
![]() |
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 |
![]() |
paulrm906 | Excel | 1 | 04-28-2006 07:35 AM |