Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-09-2018, 08:04 AM
NeviZero NeviZero is offline Macro To Delete Specific Carriage Returns Windows 10 Macro To Delete Specific Carriage Returns Office 2013
Novice
Macro To Delete Specific Carriage Returns
 
Join Date: Feb 2018
Posts: 1
NeviZero is on a distinguished road
Default Macro To Delete Specific Carriage Returns


Good Morning!!

I have a massive project in front of me, but it occurred to me that this may be very simple with a Macro. I am familiar with Macros and VBA in Excel but have never used it in Word and not really sure where to start... I have a feeling this will be relatively easy but I have no idea how to go about it...

What I am looking for is a Macro that will scan each character in the document. If that character is a Carriage Return AND the next character is also a Carriage Return then delete one of them.

Thanx a million in advance for your help! This dosument is over 3,000 pages long, and rather than letting Word wrap the text and double space it, the freaking genius that wrote hit enter twice at the end of every line... Will take me forever to fix that manually...

Thanks!!!
Nathan
Reply With Quote
  #2  
Old 02-09-2018, 09:01 AM
kilroy kilroy is offline Macro To Delete Specific Carriage Returns Windows 10 Macro To Delete Specific Carriage Returns Office 2016
Competent Performer
 
Join Date: Sep 2016
Location: Southern Ontario
Posts: 118
kilroy is on a distinguished road
Default

Try this

Code:
Sub Replace2returnsWith1()
Selection.WholeStory
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^13{2,}"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
End Sub
Reply With Quote
  #3  
Old 02-09-2018, 02:16 PM
macropod's Avatar
macropod macropod is offline Macro To Delete Specific Carriage Returns Windows 7 64bit Macro To Delete Specific Carriage Returns Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Do note you don't need a macro for this; it can be done with an ordinary Find/Replace, where:
Find = ^p^p
Replace = ^p

Kilroy's wildcard Find/Replace macro will convert all instances of two or more paragraphs to single paragraphs. If your document's creator used 3 paragraph breaks, for example, to delineate paragraphs, you will lose that delineation.

After cleaning up the paired paragraph breaks used for the double-spacing, you might be interested in cleaning up even the unnecessary single paragraph breaks with the macro in this thread: http://www.msofficeforums.com/word/2...s-e-mails.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro To Delete Specific Carriage Returns Macro to delete text in specific styles ljd108 Word VBA 14 01-22-2019 01:22 PM
Macro To Delete Specific Carriage Returns Remove Carriage Returns in Address Block Merge field alan100 Mail Merge 5 12-12-2017 08:32 PM
Macro To Delete Specific Carriage Returns Excel VBA macro to copy specific rows and delete it pourmalla Excel Programming 2 04-02-2017 12:09 AM
Macro To Delete Specific Carriage Returns Macro to delete rows not containing specific text Alimou Excel Programming 4 02-06-2017 07:35 AM
Macro To Delete Specific Carriage Returns Run Script to remove carriage returns on certain columns ryanjohnsond@gmail.com Excel Programming 34 09-03-2014 10:43 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:05 AM.


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