Thread: [Solved] Transfer text to footnotes
View Single Post
 
Old 05-13-2019, 07:47 PM
thiagoafdoria thiagoafdoria is offline Windows 8 Office 2016
Novice
 
Join Date: Feb 2017
Posts: 18
thiagoafdoria is on a distinguished road
Default

Hi there!
Sorry for taking back an old thread. The macro below transforms text in green color into footnotes.

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
I would like to change it, so that the footnotes are made from fragments between "[!" and "!]", not green text anymore. For example:

This is normal text.[!This should be turned into a footnote.!] This is normal text. This is normal text... And so on.

Is that possible?

Thank's in advance,

Thiago