Thread: [Solved] Transfer text to footnotes
View Single Post
 
Old 02-14-2017, 01:54 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The problem with your document is that it has trailing spaces & paragraph breaks formatted green. The following code revision will take care of that (plus tabs & line breaks):
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim Rng As Range, FtNt As Footnote
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = ""
    .Replacement.Text = ""
    .Forward = True
    .Format = True
    .Font.ColorIndex = wdGreen
    .Wrap = wdFindStop
    .MatchWildcards = True
    .Execute
  End With
  Do While .Find.Found
    If .Characters.Last Like "[" & vbCr & vbTab & Chr(11) & Chr(160) & " ]" Then
      .Characters.Last.Font.Reset
      .End = .End - 1
    End If
    Set Rng = .Duplicate
    .Collapse wdCollapseStart
    Set FtNt = .Footnotes.Add(.Duplicate)
    Rng.Start = FtNt.Reference.End
    FtNt.Range.FormattedText = Rng.FormattedText
    Rng.Delete
    If .End = ActiveDocument.Range.End Then Exit Sub
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]