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