View Single Post
 
Old 02-29-2024, 12:11 PM
Jakov93 Jakov93 is offline Windows 10 Office 2010
Advanced Beginner
 
Join Date: Jul 2021
Posts: 51
Jakov93 is on a distinguished road
Default Remove Paragraph Mark if the Line End with Character or Punctuation Not Full Stop

Hi,
I have this sample (attachment)
114.png
I want to remove each paragraph mark if the lines end with character or punctuation, not a full stop, to make a completely separate paragraph.

I used this code, but it removes all paragraph marks and make all text in single paragraph, which is not my requirement
Code:
Sub RemovePara()
    Dim oRng   As range
    If Len(Selection.range) = 0 Then
        MsgBox "Select the text first", vbCritical
        Exit Sub
    End If
    Set oRng = Selection.range

    With oRng.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .text = "^p"
        .Replacement.text = " "
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = False
        .Execute Replace:=wdReplaceAll
    End With
End Sub
Thanks
Attached Files
File Type: docx Sample.docx (20.3 KB, 7 views)
Reply With Quote