Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-10-2011, 08:48 PM
Jazz43 Jazz43 is offline Remove or bulk reset line breaks. Windows 7 64bit Remove or bulk reset line breaks. Office 2010 32bit
Advanced Beginner
Remove or bulk reset line breaks.
 
Join Date: Oct 2009
Posts: 54
Jazz43 is on a distinguished road
Default Remove or bulk reset line breaks.


Running Word 2007. Excuse me if I don't use the correct terminology in the following. I recently scanned a booklet, and had it converted to a PDF with text recognized. I copied and pasted the resulting text into a blank Word doc. Text is left justified. All good so far, but each line is terminating in a paragraph mark at ~ 4.5", max. I would like the lines to fit a standard 8.5 x 11 page, with 1" margins, so each line should be ~ 6.5". The doc is ~ 20 pages long. Other than going to the end of each line + deleting the paragraph mark, is there a way to accomplish this on the entire doc at once? Doc is saved as .docx.

I hope my question is clear!

Jazz43
Reply With Quote
  #2  
Old 11-13-2011, 04:40 AM
macropod's Avatar
macropod macropod is offline Remove or bulk reset line breaks. Windows 7 64bit Remove or bulk reset line breaks. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

Hi Jazz43,

Here's a macro you can use for cleaning up text pasted from the web, emails, pdfs, etc. Aside from acting on the whole document and assuming there are two (or more) paragraph breaks for each real paragraph break, and only one for each line break, there's nothing much you need to know before running it.
Code:
Sub CleanUpPastedText()
'Turn Off Screen Updating
Application.ScreenUpdating = False
With ActiveDocument.Range.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Forward = True
  .Wrap = wdFindStop
  .Format = False
  .MatchAllWordForms = False
  .MatchSoundsLike = False
  .MatchWildcards = True
  'Eliminate spaces & tabs before paragraph breaks.
  .Text = "[ ^s^t]{1,}^13"
  .Replacement.Text = "^p"
  .Execute Replace:=wdReplaceAll
  'Replace single paragraph breaks with a space
  .Text = "([!^13])([^13])([!^13])"
  .Replacement.Text = "\1 \3"
  'Replace all double spaces with single spaces
  .Execute Replace:=wdReplaceAll
  .Text = "[ ]{2,}"
  .Replacement.Text = " "
  'Delete hypens in hyphenated text formerly split across lines
  .Execute Replace:=wdReplaceAll
  .Text = "([a-z])-[ ]{1,}([a-z])"
  .Replacement.Text = "\1\2"
  .Execute Replace:=wdReplaceAll
  'Limit paragraph breaks to one per 'real' paragraph.
  .Text = "[^13]{1,}"
  .Replacement.Text = "^p"
  .Execute Replace:=wdReplaceAll
End With
'Restore Screen Updating
Application.ScreenUpdating = True
End Sub
For PC macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm
For Mac macro installation & usage instructions, see: http://word.mvps.org/Mac/InstallMacro.html

If you'd prefer to run the macro against just a selected range, change:
ActiveDocument
to:
Selection
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 11-26-2011, 10:16 PM
Jazz43 Jazz43 is offline Remove or bulk reset line breaks. Windows 7 64bit Remove or bulk reset line breaks. Office 2007
Advanced Beginner
Remove or bulk reset line breaks.
 
Join Date: Oct 2009
Posts: 54
Jazz43 is on a distinguished road
Default

Thanks for that, I'll check it out
Reply With Quote
  #4  
Old 02-11-2021, 02:03 AM
EnzoC EnzoC is offline Remove or bulk reset line breaks. Windows 10 Remove or bulk reset line breaks. Office 2019
Novice
 
Join Date: Feb 2021
Posts: 2
EnzoC is on a distinguished road
Default

Thank you for this Macro. However when I try to run it stops in line " .Execute Replace:=wdReplaceAll" : Errore di run-time 5560 Il testo nella casella Trova contiene un'espressione non valida Usa criteri di ricerca that translated is like "Run-time error 5560 Text in Find box contains invalid expression Use search criteria".
Do I have lo install some plug-in in Word/Office to make it work and possibly find the wdReplaceAll function?
I have Office 365 version
Reply With Quote
  #5  
Old 02-11-2021, 04:14 AM
macropod's Avatar
macropod macropod is offline Remove or bulk reset line breaks. Windows 10 Remove or bulk reset line breaks. Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

See the Cleaning up Text Pasted from Websites, E-mails, PDFs etc. 'Sticky' thread at the top of this forum: https://www.msofficeforums.com/word/...-pdfs-etc.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 02-11-2021, 08:36 AM
EnzoC EnzoC is offline Remove or bulk reset line breaks. Windows 10 Remove or bulk reset line breaks. Office 2019
Novice
 
Join Date: Feb 2021
Posts: 2
EnzoC is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
See the Cleaning up Text Pasted from Websites, E-mails, PDFs etc. 'Sticky' thread at the top of this forum: https://www.msofficeforums.com/word/...-pdfs-etc.html
THANK YOU!!

This works fine!!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove or bulk reset line breaks. Prevent Outlook from adding line breaks vektor Outlook 4 02-14-2012 02:16 PM
Remove or bulk reset line breaks. Paragraph line breaks muymalestado Word 3 09-25-2011 05:06 AM
Remove or bulk reset line breaks. Line breaks at each line in Web text ahazelwood Word 5 01-06-2011 02:37 PM
How would I bulk select and copy highlights and then bulk paste them automatically? copywriterpro Word 0 04-19-2010 05:21 AM
Remove or bulk reset line breaks. Unwanted line breaks P. Alkuin Word 2 03-15-2010 09:33 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:57 PM.


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