Microsoft KB Archive/63520

Word: Macros to Count Blank and Nonblank Lines

PSS ID Number: Q63520 Article last modified on 11-02-1994

5.00

MS-DOS

= SUMMARY =

To count total lines in a document, you can use the Print File function to print to “nul”. When finished, Word will return the number of lines and words printed. However, Word also includes blank lines in this value. Using a macro, you can just count blank lines (and subtract the difference), or you can count all nonblank lines (a one-step procedure).

= MORE INFORMATION =

The following are macros that count blank or nonblank lines in a document and place the count at the end of the document, formatted as hidden text. The < > represent the chevron characters created with the CTRL+[ and CTRL+] keys.

Use the following macro to count blank lines:

Count_Blank_Lines.mac^B

<> s^p^p d n n <> <>  <> < >  fcy

Use the following macro to count nonblank lines:

Count_Non-Blank.mac^N

<>  <&quot;“>> <”^p&quot;>> <> <>  <<ENDWHILE>> < > <F9> fc<up>y

KBCategory: kbother kbmacro KBSubcategory: Additional reference words: ============================================================================= Copyright Microsoft Corporation 1994.