Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-25-2017, 06:43 AM
gmaxey gmaxey is offline Replacing till there's no more double paragraphs in the text Windows 7 32bit Replacing till there's no more double paragraphs in the text Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Code:
Sub Limpa_texto()
Dim lngIndex As Long, oRng As Range
Dim strLS As String
Dim arrFind, arrReplace
  strLS = Application.International(wdListSeparator)
  arrFind = Array("^32{1,}^13", "^13^32{1,}", "^13{2,}", "^32{2,}")
  arrReplace = Array("^p", "^p", "^p", " ")
  Set oRng = ActiveDocument.Range
  Application.ScreenUpdating = False
  For lngIndex = 0 To UBound(arrFind)
    With oRng.Find
      .Text = Replace(arrFind(lngIndex), ",", strLS)
      .Replacement.Text = Replace(arrReplace(lngIndex), ",", strLS)
      .MatchWildcards = True
      .Execute Replace:=wdReplaceAll
    End With
  Next lngIndex
  'Deal with dispersed tables and final paragraph.
  For lngIndex = ActiveDocument.Range.Paragraphs.Count To 1 Step -1
    If Len(ActiveDocument.Range.Paragraphs(lngIndex).Range.Text) = 1 Then
      ActiveDocument.Range.Paragraphs(lngIndex).Range.Delete
    End If
  Next
  Application.ScreenUpdating = True
lbl_Exit:
  Exit Sub
End Sub

__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #2  
Old 06-25-2017, 03:22 PM
eduzs eduzs is offline Replacing till there's no more double paragraphs in the text Windows 10 Replacing till there's no more double paragraphs in the text Office 2010 32bit
Expert
Replacing till there's no more double paragraphs in the text
 
Join Date: May 2017
Posts: 266
eduzs is on a distinguished road
Default

Hi gmaxey, just one more little question, how can I merge two lines of text?

"The book is on the blue^p
table next to the door."

Result:

"The book is on the blue table next to the door."

I did this: "[!.:;]^13" to "^p", but does not work, the last character of the 1st paragraph disapear, resulting in "The book is on the blu table..."

Note that the code should only join the rows if "^ p" is not preceded by "." or ";" or ":".

Ps.: I did a trick, two passes, "[!.:;]^13", "^13¢", replace to "^&¢", " ".
Seems to work fine.

Thanks.
__________________
Backup your original file before doing any modification.

Last edited by eduzs; 06-25-2017 at 07:08 PM.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Replacing till there's no more double paragraphs in the text Help with replacing text with wildcards sbatson5 Word 2 04-13-2012 03:49 AM
Why the "Text boundaries" are not shown till the end of the page while in other file Jamal NUMAN Word 4 03-28-2012 07:58 AM
Replacing till there's no more double paragraphs in the text outlook double spacing paragraphs GWBDIRECT Outlook 3 04-06-2011 11:29 AM
Replacing till there's no more double paragraphs in the text Replacing a single "l" with a double "ll" MShroff Word 8 01-19-2011 08:43 AM
Replacing / editting text LisaC Word 0 02-25-2010 03:40 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:29 AM.


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