View Single Post
 
Old 08-02-2021, 04:49 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,164
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

Since nearly all of the paragraphs in the footnotes are going to start with a footnote reference, a find replace is less useful. Try this variation
Code:
Sub BracketFootnotes()
  Dim rg As Range, aPar As Paragraph, rngRef As Range
  
  Set rg = ActiveDocument.Range
  With rg.Find
    .Format = True
    .Style = ActiveDocument.Styles(wdStyleFootnoteReference)
    .Wrap = wdFindStop
    While .Execute
      If rg.Characters(1) <> "(" Then
      rg.InsertBefore "("
      rg.InsertAfter ")"
      rg.Style = ActiveDocument.Styles(wdStyleFootnoteReference)
      End If
      rg.Collapse wdCollapseEnd
    Wend
  End With
  Set rg = Nothing
  
  Set rg = ActiveDocument.StoryRanges(wdFootnotesStory)
  For Each aPar In rg.Paragraphs
    Set rngRef = aPar.Range.Words.First
    rngRef.End = rngRef.Start + Len(Trim(rngRef.Text))
    rngRef.Select
    If rngRef.Characters.First.Style = "Footnote Reference" And rngRef.Characters.First <> "(" Then
      rngRef.InsertBefore "("
      rngRef.InsertAfter ")"
      rngRef.Style = wdStyleFootnoteReference
    End If
  Next aPar
  Set rg = Nothing
  Set rngRef = Nothing
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote