Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Finding Long Lines.

Finding Long Lines

Written by Allen Wyatt (last updated August 31, 2020)
This tip applies to Word 97, 2000, 2002, and 2003


Lori asked for an easy way to determine if a paragraph "spills over" to more than one line. It seems that when Lori was merging labels, if a line (paragraph) runs over and wraps to the next line on the label, she wanted to reduce the point size on the text so that the line occupied just that—a single line.

Wrapping lines is a real-time (and print-time) feature of Word. Word performs internal calculations continuously to work out what to display on screen or what to print on paper. Where text wraps from one line to another there is actually nothing to mark the point of wrap (as there is in some other word processors), so there's nothing to actually search for or find. In addition, Word's Find feature does not have an option (special or otherwise) to seek stuff and say how many lines the found stuff spreads over.

It is possible to do a long series of search-and-replace operations to try to "fudge" and find out the too-long lines. For instance, you could follow these general steps:

  1. Replace all spaces in a merged document with some standard character combination, such as [s].
  2. Replace all dashes in a merged document with some standard character combination, such as [d].
  3. Now, all paragraphs in the document consist of a single, run-together word.
  4. Run the hyphenation tool to manually hyphenate the document.
  5. Whenever Word finds a line that needs to be hyphenated, you can decrease the point size of that line.
  6. Redo your replacements, return [s] and [d] to their normal spaces and dashes.

This may sound a bit convoluted, and it is. But it will work fairly well, unless you want to get into writing a macro. (Believe it or not, even if you don't use macros that often, this particular macro is much easier than doing the above steps over and over again.)

When trying to decide how to put the macro together, a sad discovery awaits us in VBA. Veteran Word users will remember that when you use the Word Count feature in Word, the program shows you the number of lines in your document. This would imply that you can use VBA to determine the number of lines in a selection. Unfortunately, the ReadabilityStatistics property in VBA doesn't return a statistic for the number of lines. That means that the statistic shown in the Word Count dialog box is internally calculated as needed.

The only apparent solution is to rely upon the Information property for wdFirstCharacterLineNumber, which returns the line number for the first character in a selection. Unfortunately, there is no wdLastCharacterLineNumber specified in VBA, so the macro must make a selection for the first character in a paragraph, compare it to a selection of the last character in a paragraph, and see if the same two line numbers are returned. If they aren't, then the point size of the paragraph can be reduced and another calculation done.

The following VBA macro, ParaforceOneLine, does just this process. It examines each paragraph in a document, and if any given paragraph runs over a single line, the point size of that particular paragraph is reduced until it can fit on a single line.

Sub ParaForceOneLine()
    Dim objPara As Paragraph
    Const ChangeSize = 0.5

    For Each objPara In ActiveDocument.Paragraphs
        With objPara.Range
            While .Information(wdFirstCharacterLineNumber) <> _
              .Characters(Len(.Text)).Information(wdFirstCharacterLineNumber)
                .Font.Size = .Font.Size — ChangeSize
            Wend
        End With
    Next objPara
End Sub

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 (1415) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Finding Long Lines.

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

Doubling Your Money

Make your money last longer by using your head when printing labels. Here's a great example of how you can double the ...

Discover More

Replacing Formatting Functions as a Toggle

Sarra is having a problem getting Find and Replace to behave properly when replacing italic-formatted text. This tip ...

Discover More

Returning Zero When a Referenced Cell is Blank

Reference a cell in a macro, and if that cell is blank Excel normally equates that to a zero value. What if you don't ...

Discover More

Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!

More WordTips (menu)

Defining a Shortcut for a Macro

You can make running macros very easy if you assign a shortcut key to the macro. This tip demonstrates how easy it is to ...

Discover More

Bypassing the Startup Macro

Word allows you to create a macro that is run automatically whenever the program is started. If you want to bypass the ...

Discover More

Repaginating Your Document in a Macro

When processing a document with a macro, you may need to have the macro repaginate the text. It's easy to do using the ...

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 6 - 0?

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 menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon 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.