View Single Post
 
Old 12-09-2019, 08:00 PM
thiagoafdoria thiagoafdoria is offline Windows 10 Office 2019
Novice
 
Join Date: Feb 2017
Posts: 18
thiagoafdoria is on a distinguished road
Default Excluding specific signs when transforming texto into footnotes

Hi there!
I use the following macro, which was kindly constructed by macropod:

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 = False
    .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'm having trouble making a small change. This macro transforms text between "[!" and "!]" into footnotes. But I'd like to also exclude those signs, "[!" and "!]" in the final result, that is, the content of the footnote. For example:

- In the body: [!This is x.!]
- In the footnote: This is x.

I guess I'd have to write make another line in the macro, but I don't have any idea of what I should write there.
Somebody could help?
Thank's!
Reply With Quote