Re: How to strip lots of carriage returns (paragraph marker) in Word?
From: Greg Maxey (gmaxey_at_whamspammvps.org)
Date: 09/07/04
- Next message: Greg Maxey: "Re: Insert file Name & Path"
- Previous message: Greg Maxey: "Re: How can I delete solid lines formed from lines of hyphens?"
- In reply to: BrucePT: "How to strip lots of carriage returns (paragraph marker) in Word?"
- Next in thread: Suzanne S. Barnhill: "Re: How to strip lots of carriage returns (paragraph marker) in Word?"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 7 Sep 2004 15:27:36 -0400
Bruce,
I use this macro and function:
Sub CleanUpText()
Dim EP As Paragraph
Dim TextChar As String
If MsgBox("Do you want to remove leading spaces or characters?", vbYesNo) =
vbYes Then
Call CUTReplaceSpecific("< {1,}*", "")
Call CUTReplaceSpecific("(^13)( {1,}*)", "\1")
Call CUTReplaceSpecific("(^l)( {1,}*)", "\1")
Call CUTReplaceSpecific("( {1,})(^13)", "\2")
Call CUTReplaceSpecific("( {1,})(^l)", "\2")
Call CUTReplaceSpecific("([\>]{1,})( {1,})", "")
Call CUTReplaceSpecific("(^l)([\> ]{1,})", "\1")
Call CUTReplaceSpecific("(^13)([\> ]{1,})", "\1")
Call CUTReplaceSpecific("(^l)([\<]{1,})", "\1")
Call CUTReplaceSpecific("(^13)([\<]{1,})", "\1")
Call CUTReplaceSpecific("(^13)( {1,})", "\1")
Call CUTReplaceSpecific("(^l)( {1,})", "\1")
Do
TextChar = InputBox("Type in any additional leading character")
ActiveDocument.Range(0, 0).Select
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = False
.Text = TextChar
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
End With
Loop While TextChar > ""
Call CUTReplaceSpecific("< {1,}*", "")
End If
If MsgBox("Do you want to replace linebreaks with paragraph fromatting?",
vbYesNo) = vbYes Then
Call CUTReplaceSpecific("^l{2,}", "^p")
Call CUTReplaceSpecific("^l{1,}", " ")
End If
If MsgBox("Do you want to delete empty paragraphs in this document?",
vbYesNo) = vbYes Then
For Each EP In ActiveDocument.Paragraphs
If Len(EP.Range.Text) = 1 Then EP.Range.Delete
Next EP
End If
End Sub
Function CUTReplaceSpecific(sSearchFor As String, sReplaceWith As String)
'CUT is Clean Up Text
ActiveDocument.Range(0, 0).Select
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = True
.Text = sSearchFor
.Replacement.Text = sReplaceWith
.Execute Replace:=wdReplaceAll
End With
End Function
-- Greg Maxey A peer in "peer to peer" support Rockledge, FL To e-mail, edit out the "w...spam" in gmaxey@whamspammvps.org BrucePT wrote: > Importing or pasting text with embedded CRLFs creates ugly manual > edit task. Any convenient way to edit/strip these in Word? Other > free/cheap utility? Can't find any paste special option, escape > character, or editing options in Help or MS Web site that let me do > this. > > Thanks,
- Next message: Greg Maxey: "Re: Insert file Name & Path"
- Previous message: Greg Maxey: "Re: How can I delete solid lines formed from lines of hyphens?"
- In reply to: BrucePT: "How to strip lots of carriage returns (paragraph marker) in Word?"
- Next in thread: Suzanne S. Barnhill: "Re: How to strip lots of carriage returns (paragraph marker) in Word?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|