Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-14-2023, 11:25 PM
RobiNew RobiNew is offline Remove empty paragraphs typed before paragraph marks Windows 10 Remove empty paragraphs typed before paragraph marks Office 2016
Competent Performer
Remove empty paragraphs typed before paragraph marks
 
Join Date: Sep 2023
Posts: 183
RobiNew is on a distinguished road
Smile 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
Reply With Quote
Reply



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 empty paragraphs typed before paragraph marks 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 empty paragraphs typed before paragraph marks Remove consecutive empty paragraphs within existing macro kevinbradley57 Word VBA 5 10-11-2017 05:04 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:35 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft