View Single Post
 
Old 11-02-2023, 03:17 AM
RobiNew RobiNew is offline Windows 10 Office 2016
Competent Performer
 
Join Date: Sep 2023
Posts: 200
RobiNew is on a distinguished road
Default Replace a hard return with a dash in the text of a footnote

I devised this macro to replace a hard return with a dash in the text of a footnote. Sometimes it works correctly, but sometimes it gives an error as if it tried to replace also footnote ending paragraphs. Any idea? Thanks!
Code:
Sub ReplRefNrWithinFootnote()
'Replaces with dash paragraph mark in the text of a footnote
Set parRng = ActiveDocument.StoryRanges(wdFootnotesStory)
    With parRng.Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Wrap = wdFindStop
      .Format = False
      .MatchWildcards = True
      .Text = (Chr(13)) & "([!^02])" 'avoid ref. numbers
      .Execute
    While .Execute
      parRng.Text = Replace(parRng.Text, Chr(13), " " & Chr(150) & " ")
    Wend
    End With
End Sub
Reply With Quote