#1
|
|||
|
|||
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 |
#2
|
|||
|
|||
Hi, RobiNew! Try this:
Code:
Sub ReplRefNrWithinFootnote() 'Replaces with dash paragraph mark in the text of a footnote Set parRng = ActiveDocument.StoryRanges(wdFootnotesStory) On Error Resume Next With parRng.Find .ClearFormatting .Replacement.ClearFormatting .Wrap = wdFindStop .Format = False .MatchWildcards = False .text = "^p" While .Execute And parRng.End < ActiveDocument.StoryRanges(wdFootnotesStory).End parRng.text = Replace(parRng.text, Chr(13), " " & Chr(150) & " ") parRng.Collapse wdCollapseEnd Wend End With End Sub |
#3
|
|||
|
|||
Thanks a lot, Vivka! This one seems to work without exception.
|
#4
|
|||
|
|||
See you next time, RobiNew!
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro for Find/replace to remove space before Hard Return | AlfredStreich | Word VBA | 4 | 01-23-2020 03:59 PM |
Find / Replace hard Carriage Return with Line break. | GreenBoy | Word | 2 | 03-11-2018 02:32 AM |
curly quotes after em-dash or hard space | btorrance | Word | 0 | 06-07-2013 07:39 AM |
Hard return renders upper case | clafond | Word | 2 | 01-07-2013 12:26 PM |
Hard page return? | markg2 | Outlook | 0 | 09-11-2012 08:49 AM |