![]() |
#9
|
|||
|
|||
![]()
Graham, thanks!
Break eduzs, I'm not entirely sure that I know what your goal really is, but if it is to remove empty paragraphs and leading or trailing spaces from paragraphs then I think your current version falls short. And to each his own and perhaps it is due to habit or what you have seen before, but I can't for the life of me see any advantage of your two Do ... While loops or use of the seemingly redundant Find.Found. 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 If Len(ActiveDocument.Range.Paragraphs.Last.Range) = 1 Then ActiveDocument.Range.Paragraphs.Last.Range.Delete End If Application.ScreenUpdating = True lbl_Exit: Exit Sub End Sub |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
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 |
![]() |
GWBDIRECT | Outlook | 3 | 04-06-2011 11:29 AM |
![]() |
MShroff | Word | 8 | 01-19-2011 08:43 AM |
Replacing / editting text | LisaC | Word | 0 | 02-25-2010 03:40 AM |