Removing Extra Paragraph Marks

by Allen Wyatt
(last updated August 20, 2016)

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.

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

Sub ReplacePara()
    Selection.HomeKey Unit:=wdStory
    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
    While Selection.Find.Found
        Selection.MoveRight Unit:=wdCharacter, Count:=1
        Selection.MoveLeft Unit:=wdCharacter, Count:=2
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. The macro doesn't replace the sequential paragraph marks; 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).

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, and 2016.

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. ...


Counting with PivotTables

One of the ways you can use PivotTables is to generate counts of various items in a data table. This is a great technique if ...

Discover More

Turning Off Sharing

All good things must come to an end at some point. When you are done sharing your workbook with others, this is how you can ...

Discover More

Tracing Precedent Cells

Cells that affect another cell are called precedent cells. If you need to know which cells affect a particular cell, Excel ...

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!


Automatically Identifying Repeated Words

Need to find out how many times words are repeated in a document? If so, you'll appreciate the discussion in this tip about ...

Discover More

Typing Pronunciations of Words

Take a look in a dictionary at the way that words are phonetically spelled. Those special characters used to type those ...

Discover More

Getting the Proper Type of Ellipses

Type three periods in a row, and the AutoCorrect feature in Word kicks in to exchange that sequence for a special ellipses ...

Discover More

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 for this tip:

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)

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.


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.

Links and Sharing