Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, and 2013. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Finding Long Lines.
by Allen Wyatt
(last updated January 3, 2015)
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:
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 lobjPara 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
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (9954) applies to Microsoft Word 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Word here: Finding Long Lines.
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!
An array of variables is a powerful element of VBA programming. If you want to clear what is stored in an array, here's a ...Discover More
When processing a document using a macro, you may need to know if the insertion point is within a bookmark or not. This is ...Discover More
Formulas created in a macro have a specific order in which operations are performed. This is known as precedence, as ...Discover More
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
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.