Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-29-2024, 12:11 PM
Jakov93 Jakov93 is offline Remove Paragraph Mark if the Line End with Character or Punctuation Not Full Stop Windows 10 Remove Paragraph Mark if the Line End with Character or Punctuation Not Full Stop Office 2010
Advanced Beginner
Remove Paragraph Mark if the Line End with Character or Punctuation Not Full Stop
 
Join Date: Jul 2021
Posts: 45
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, 5 views)
Reply With Quote
  #2  
Old 03-01-2024, 08:44 AM
vivka vivka is offline Remove Paragraph Mark if the Line End with Character or Punctuation Not Full Stop Windows 7 64bit Remove Paragraph Mark if the Line End with Character or Punctuation Not Full Stop Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 227
vivka is on a distinguished road
Default

Hi! Try this one:
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 = "([!.])" & Chr(13)
        .Replacement.text = "\1 "
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
End Sub
Reply With Quote
  #3  
Old 03-01-2024, 09:01 AM
Jakov93 Jakov93 is offline Remove Paragraph Mark if the Line End with Character or Punctuation Not Full Stop Windows 10 Remove Paragraph Mark if the Line End with Character or Punctuation Not Full Stop Office 2010
Advanced Beginner
Remove Paragraph Mark if the Line End with Character or Punctuation Not Full Stop
 
Join Date: Jul 2021
Posts: 45
Jakov93 is on a distinguished road
Default

Quote:
Originally Posted by vivka View Post
Hi! Try this one:
Thanks vivka
It works perfectly
Thanks so much
Reply With Quote
  #4  
Old 03-01-2024, 09:59 AM
vivka vivka is offline Remove Paragraph Mark if the Line End with Character or Punctuation Not Full Stop Windows 7 64bit Remove Paragraph Mark if the Line End with Character or Punctuation Not Full Stop Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 227
vivka is on a distinguished road
Default

You are welcome, Jakov93!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove spaces before each paragraph mark in text and footnotes RobiNew Word VBA 33 10-17-2023 01:14 AM
How do I add a missing full stop / period at the end of a paragraph? Helend269 Word VBA 2 10-08-2020 10:18 AM
Remove Paragraph Mark if the Line End with Character or Punctuation Not Full Stop Large first character in paragraph causing extra line space dustnik Word 11 09-04-2019 12:47 AM
Paragraph mark after horizontal line is way to the right. DBlomgren Word 0 02-09-2014 11:42 PM
Remove Paragraph Mark if the Line End with Character or Punctuation Not Full Stop Replace paragraph-marks (line-breaks) in tables with a character-string Aztec Word VBA 2 04-02-2013 10:52 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:07 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