#1
|
|||
|
|||
Remove empty paragraphs typed before paragraph marks
I've devised this macro to remove empty paragraphs before a footnote, that is: paragraphs previously inserted before the footnote mark in the footnote sector. The macro does its job, but I cannot avoid Runtime Error: 5252. Can someone help? Thanks!
Code:
Sub Remove () Set rng = ActiveDocument.StoryRanges(wdFootnotesStory) With rng.Find .Text = "^13{2;}" .MatchWildcards = True .Execute End With If rng.Find.Found = True Then For n = 1 To 10 rng.MoveUntil rng Like "^#" rng.Select rng.Collapse Direction:=wdCollapseEnd rng.MoveUntil rng Like ".", Extend On Error GoTo Quit rng.Delete , -1 'Runtime Error: 5252 On Error GoTo 0 Next n End If Quit: End Sub I modified the macro. The code here below now works perfectly. Code:
Sub Remove2 () Set rng = ActiveDocument.StoryRanges(wdFootnotesStory) With rng.Find .Text = "^13{2;}" .MatchWildcards = True .Execute End With If rng.Find.Found = True Then rng.MoveUntil rng Like "^#" rng.Select For n = 1 To Len(rng) - 1 rng.Collapse Direction:=wdCollapseEnd rng.MoveUntil rng Like ".", Extend rng.Delete , -1 Next n End If End Sub Last edited by RobiNew; 10-15-2023 at 06:56 AM. Reason: New code |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
a macro to replace paragraph mark with a space applies effect on paragraph marks after the selection | drrr | Word VBA | 2 | 08-24-2021 03:05 AM |
Remove the hyperlinks on paragraph marks | alex100 | Word VBA | 4 | 12-31-2020 09:00 AM |
Remove paragraph marks in Excel from Word-sourced text | Peterson | Excel | 6 | 08-18-2020 11:36 PM |
Help me, remove the marks occur at begin and last paragraph | ngocanhwdn | Word | 6 | 06-25-2019 07:57 AM |
Remove consecutive empty paragraphs within existing macro | kevinbradley57 | Word VBA | 5 | 10-11-2017 05:04 PM |