Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 06-25-2017, 07:57 AM
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: 262
eduzs is on a distinguished road
Default


Thanks a lot! Works fine.
We can set this thread as solved.
__________________
Backup your original file before doing any modification.
Reply With Quote
  #17  
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: 262
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
  #18  
Old 06-25-2017, 08:09 PM
gmayor's Avatar
gmayor gmayor 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 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You can do it in one
Replace
([!.:;"'])^13
with \1 (followed by a space)
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #19  
Old 06-26-2017, 02:56 AM
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: 262
eduzs is on a distinguished road
Default

Wildcard is like magic.
Thanks again!

"Final" code, for collaboration purposes:

Quote:
Sub Text_Cleaner()

Dim i As Long, opMsg As Integer, oRng As Range, oPara As Range, aProc, aSubs

aProc = Array("^255", "^13^32", "^32{1;}^13", "^13^32{1;}", "^13{2;}", "^32{2;}", "([!.:;""])^13")
aSubs = Array("", "^p", "^p", "^p", "^p", " ", "\1 ")

If Selection.Words.Count = 1 Then

Set oRng = ActiveDocument.Range
opMsg = 1

Else

Set oRng = Selection.Range
opMsg = 2

End If

If MsgBox("Clean-up " & IIf(opMsg = 1, "activedocument", "selected range") & "?", vbYesNo + vbExclamation, " CONFIRMATION!") = vbNo Then Exit Sub

Application.ScreenUpdating = False

For i = 0 To UBound(aProc)

With oRng.Find
.ClearFormatting
.Text = aProc(i)
.Replacement.Text = aSubs(i)
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With

Next i

Set oPara = oRng.Paragraphs(1).Range

If Left(oPara.Text, 1) = " " Then oPara.Text = Right(oPara.Text, Len(oPara.Text) - 1)

If Len(ActiveDocument.Range.Paragraphs.Last.Range) = 1 Then ActiveDocument.Range.Paragraphs.Last.Range.Delete

Application.ScreenUpdating = True

End Sub
__________________
Backup your original file before doing any modification.
Reply With Quote
  #20  
Old 06-26-2017, 04:45 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,427
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Your code as posted won't work for me. f you really want to collaborate then you should include the bit about:
Dim arrFind, arrReplace
strLS = Application.International(wdListSeparator)
etc.,
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #21  
Old 06-28-2017, 04: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: 262
eduzs is on a distinguished road
Default

Hi there gmaxey, I was thinking about a more user-frendly code, but I did a lot of customization and the code should not be useful for everyone.
I have a new question:
In this mask: "([!.:;""])^13" how can I set not only a single caracter exception, but two or more, something like "([!.:'0 ;';""])^13" or "([!.:;'mary'""])^13"
Thanks
__________________
Backup your original file before doing any modification.
Reply With Quote
  #22  
Old 06-28-2017, 08:01 PM
gmayor's Avatar
gmayor gmayor 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 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

See http://www.gmayor.com/replace_using_wildcards.htm
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #23  
Old 06-28-2017, 10:54 PM
macropod's Avatar
macropod macropod is offline Replacing till there's no more double paragraphs in the text Windows 7 64bit Replacing till there's no more double paragraphs in the text Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Word's Find/Replace routine will not find empty paragraphs before a table. You need a different approach for that. For example:
Code:
Sub Demo()
Dim Tbl As Table, Rng As Range
On Error Resume Next
For Each Tbl In ActiveDocument.Tables
  Set Rng = Tbl.Range.Characters.First.Previous
  Rng.MoveStartWhile vbCr, -1
  Rng.Delete
Next
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #24  
Old 06-29-2017, 03:12 AM
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: 262
eduzs is on a distinguished road
Default

Thanks macropod and gmaxey.
I was trying to modify this mask unsucessfull.
"([!.:;""])^13"
Works fine and does not find when there's a !, ., : or ; (for a single character it works fine).
The problem is that I want it to not find also when there's a exact sequence of character like "xyz".
I tried with "([!.:;<xyz>""])^13" not works.
I read the link but didn't find something exactly like I was looking for.
__________________
Backup your original file before doing any modification.
Reply With Quote
  #25  
Old 06-29-2017, 07:00 PM
macropod's Avatar
macropod macropod is offline Replacing till there's no more double paragraphs in the text Windows 7 64bit Replacing till there's no more double paragraphs in the text Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
Find = ([!.:;]xyz[" & Chr(34) & "”])^13
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #26  
Old 07-01-2017, 04:04 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: 262
eduzs is on a distinguished road
Default

Macropod, gmaxey, gmayor thanks for helping.
Gmaxey and gmayor, I really liked your site, several examples of useful macros, developing macros for word, I think, is not as easy or intuitive as for excel, so we need forum help all the time.
I think much of the difficulty of development is because of the endless number of objects and countless properties, in excel vba you can meet 90% of your needs only with workbook, sheets and cells objects.
__________________
Backup your original file before doing any modification.

Last edited by eduzs; 07-01-2017 at 07:18 PM.
Reply With Quote
Reply

Thread Tools
Display Modes


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 02:13 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