Dear Peterson, after applying your code, I think this portion of your code is not necessary at least according to my case

, so I will remove it.
Quote:
Originally Posted by Peterson
Code:
Sub CleanUpBlankLines()
' Remove spaces between empty paragraphs, in preparation
' to remove paragraphs preceding numbers:
.Text = "(^13)( {1,})(^13)"
.Replacement.Text = "\1\3"
.Execute Replace:=wdReplaceAll
' Remove empty paragraphs preceding numbers:
.Text = "([^13]{2,})([0-9])"
.Replacement.Text = "^13\2"
.Execute Replace:=wdReplaceAll
End Sub
|
Now, this code is ok
Code:
Sub GapRemoving4Paragraph()
' Finds paragraph marks and spaces between broken paragraphs and removes them
Application.ScreenUpdating = False
Dim oRange As range
Set oRange = ActiveDocument.range
With oRange.Find
.ClearFormatting
.Replacement.ClearFormatting
.MatchWildcards = True
' Remove gaps in text:
.Text = "([!0-9] )([^13 ]{1,})([!0-9])"
.Replacement.Text = "\1\3"
.Execute Replace:=wdReplaceAll
End With
With oRange.Find
.ClearFormatting
.Replacement.ClearFormatting
.MatchWildcards = False
End With
Set oRange = Nothing
Application.ScreenUpdating = True
End Sub
But the only problem is that sometimes the lines of each paragraph are followed by a return mark, and this code is not removing them, as Word considers each line as a separate paragraph, so how to fix it, please?
See attached file