Removing carriage returns

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

Having imported a block of text I find that each line is
interrupted by a carriage return after about 6 words. I'd
like these to be removed so that the text "rolls out" to
a normal line size of 10 or so words.


Any tips on how to do it without laboriously removing
each one individually?

Thanks
Tom
 
This subroutine should do what you want.

Sub ClearXtraCarriageReturns()
'
Dim rngStartMarker As Word.Range
Set rngStartMarker = Selection.Range

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "([!^13])(^13)([!^13])"
.Replacement.Text = "\1 \3"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

rngStartMarker.Select
End Sub

Steve
 
You could use the Find and Replace feature to replace your paragraph marks.
Click on Edit, Replace, click in the Find What box and then click on More,
and click on Special, then Paragraph Mark. Click on Replace All
 
I tried your program, but it removed all the carriage returns thu
combining the whole article into one paragraph. Can you give me som
hints to add some "AI" function to the program so that it can make m
work more convenient, e.g. I can manually add one blank paragraph (
single return occupying a line) to "mark" out separations, then th
program leave those separations thus the article will not be combine
into one?

Steve said:
*This subroutine should do what you want.

Sub ClearXtraCarriageReturns()
'
Dim rngStartMarker As Word.Range
Set rngStartMarker = Selection.Range

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
..Text = "([!^13])(^13)([!^13])"
..Replacement.Text = "\1 \3"
..Forward = True
..Wrap = wdFindContinue
..Format = False
..MatchCase = False
..MatchWholeWord = False
..MatchAllWordForms = False
..MatchSoundsLike = False
..MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

rngStartMarker.Select
End Sub

Steve
Tom said:
Having imported a block of text I find that each line is
interrupted by a carriage return after about 6 words. I'd
like these to be removed so that the text "rolls out" to
a normal line size of 10 or so words.


Any tips on how to do it without laboriously removing
each one individually?

Thanks
Tom


-
TheseusYan
 
Back
Top