View Single Post
 
Old 11-17-2023, 04:00 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

If the text formatting is coming from the underlying paragraph style then you won't get it but local character formatting will be preserved by this modification.
Code:
Sub Macro1()
  Dim oRng As Range, oFN As Footnote, rngInner As Range
  Set oRng = ActiveDocument.Range
  With oRng.Find
    Do While .Execute(FindText:="\[\[(*)\]\]", MatchWildcards:=True)
      Set oFN = ActiveDocument.Footnotes.Add(oRng, , oRng.Text)
      Set rngInner = oRng.Duplicate
      rngInner.MoveStart Unit:=wdCharacter, Count:=2
      rngInner.MoveEnd Unit:=wdCharacter, Count:=-2
      oFN.Range.FormattedText = rngInner.FormattedText
      oRng.Text = ""
    Loop
  End With
lbl_Exit:
  Set oRng = Nothing
  Set rngInner = Nothing
  Exit Sub
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote