How to Remove manual line breaks from word docs?

G

Guest

Need to learn how to remove hard line breaks from a Word.doc to allow text
flow the entire witdth of page.

This document is 85 pages and can remove line by line but this would take
hours.

Thank you in advance for input and assistance.

VB
 
G

Greg Maxey

vicb

This macro will clean up line breaks. See:
http://www.gmayor.com/installing_macro.htm if you need help applying:

Sub CleanUpText()

Dim EP As Paragraph
Dim TextChar As String
Dim bCutChars As Boolean

If MsgBox("Do you want to remove leading spaces or characters?", vbYesNo) =
vbYes Then
ActiveDocument.Range(0, 0).Select
Selection.Range.InsertAfter Chr(13)
bCutChars = True
CUTReplaceSpecific "(^13)( {1,})", "\1"
CUTReplaceSpecific "(^l)( {1,})", "\1"
CUTReplaceSpecific "(^l)([\> ]{1,})", "\1"
CUTReplaceSpecific "(^13)([\> ]{1,})", "\1"
CUTReplaceSpecific "(^l)([\<]{1,})", "\1"
CUTReplaceSpecific "(^13)([\<]{1,})", "\1"
CUTReplaceSpecific "(^13)( {1,})", "\1"
CUTReplaceSpecific "(^l)( {1,})", "\1"
CUTReplaceSpecific "( {1,})(^13)", "\2"
CUTReplaceSpecific "( {1,})(^l)", "\2"
Do
TextChar = InputBox("Type a single character of the next leading
character" _
& " that you want to remove. Click cancel to exit.")
If TextChar = "" Then
Exit Do
ElseIf InStr("*(){}[]!@?", TextChar) > 0 Then
CUTReplaceSpecific "(^13)\" & TextChar & "{1,}", "\1"
CUTReplaceSpecific "(^l)\" & TextChar & "{1,}", "\1"
Else
CUTReplaceSpecific "(^13)" & TextChar & "{1,}", "\1"
CUTReplaceSpecific "(^l)" & TextChar & "{1,}", "\1"
End If
Loop While TextChar > ""
End If
If MsgBox("Do you want to replace linebreaks with paragraph fromatting?",
vbYesNo) = vbYes Then
CUTReplaceSpecific "^l{2,}", "^p"
CUTReplaceSpecific "^l", " "
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
ElseIf bCutChars Then
ActiveDocument.Range(0, 0).Select
ActiveDocument.Paragraphs(1).Range.Delete
End If

End Sub
 
G

Guest

Use Edit>Replace & click [More], [Special] and insert the appropriate
character as your Find, type a space in the Replace field.

HTH |:>)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top