Removing Extra Paragraph Marks

Written by Allen Wyatt (last updated May 20, 2023)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021


2

There may be times when you are working with a document when you have a need to remove extra paragraph marks. This is particularly true if you are working with an ASCII file or a file that may have originally been formatted with another word processor. This process of manually removing extra paragraph marks can be very time consuming.

The traditional way of handling such situations is to use Find and Replace to search for two paragraph marks (^p^p) and replace with a single paragraph mark (^p). That works great, except in one situation—when the two paragraphs are formatted differently. In that case, a simple Find and Replace can mess up your document's formatting.

If you find yourself in this situation, you may find this macro of interest. It removes extra paragraph marks from a document using a two-step approach. When it is completed, there should not be even two paragraph marks in a row in your document.

Sub ReplacePara()
    Selection.HomeKey Unit:=wdStory
    Selection.Find.ClearFormatting
    With Selection.Find
        .Text = "^p^p"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    While Selection.Find.Found
        Selection.MoveRight Unit:=wdCharacter, Count:=1
        Selection.TypeBackspace
        Selection.MoveLeft Unit:=wdCharacter, Count:=2
        Selection.Find.Execute
    Wend
End Sub

There are two parts to this macro. The first part—which relies on the Selection.Find method—uses Word's built-in Find and Replace capabilities to find all instances of two paragraph marks in sequence. (Just as is done in the traditional Find and Replace method described earlier.) The macro doesn't replace the sequential paragraph marks, however; it simply finds them. Then the second part of the macro kicks in—using the Selection.Find.Found property to delete the second of the two sequential paragraph marks.

The reason this approach is taken is because it leaves the formatting correct on the remaining paragraph mark. For instance, if the two sequential paragraph marks use different formatting from each other, the formatting of the first paragraph mark remains unchanged. If you simply replaced the sequential paragraph marks with a single paragraph mark, it is possible that you may not have the formatting exactly as you want when the replacing is finished.

Note that Selection.Find.Found is used as a "flag" for the While loop. This property reflects the status of the latest Find operation. If True then the search was successful; if False, then there was nothing found (and, therefore, nothing to change).

Note:

If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (998) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Using Large Toolbar Buttons

Having trouble seeing the icons used on the various Word toolbars? You can make the tools larger (and easier to see) by ...

Discover More

Changing Input Conventions

Different cultures have different conventions for displaying numbers and for parameters in Excel's worksheet functions. ...

Discover More

Aligning Paragraphs in a Macro

Using a macro to format your document (or portions of your document) is not all that uncommon. If you want your macro to ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More WordTips (ribbon)

Using the Copy or Move Text Keys

Most people use the Clipboard to copy and move text in Word. Before the Clipboard, Word used F2 to move text and Shift+F2 ...

Discover More

Quickly Finding Synonyms

If you need to find some synonyms for a specific word in your document, here's how you can do it. (Hint: All you need to ...

Discover More

Inserting a Section Mark

Section marks are used regularly in the writings of some industries, such as in legal documents. If you need a way to ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is four minus 0?

2023-06-08 18:05:40

Rajan

Is there a way the code can be run only on a selected part of the document and not the entire document?


2023-05-22 09:41:20

Andrew

How about still using Find-and-Replace, but with Wildcards, something like replacing "^13{0,}(^13)" with "\1"?

Not tested - just a thought.


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.