![]() |
|
![]() |
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
![]()
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 |
#2
|
|||
|
|||
![]()
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 |
#3
|
|||
|
|||
![]() |
#4
|
|||
|
|||
![]()
You are welcome, Jakov93!
|
![]() |
|
![]() |
||||
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 |
![]() |
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 |
![]() |
Aztec | Word VBA | 2 | 04-02-2013 10:52 PM |