Line Count Macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

HELP! I need to know how to set up a macro that will count the number of lines in a document that have at least 1 letter or 1 number on that line. The line count program in the tools box counts all the lines, including the blank ones and I need to only count the total number of lines with text on them.

I am a newbie when it comes to macros so any and all help will be greatly appreciated

I have a macro set up in WordPerfect that someone else composed to do a line count, but it doesn't work in Word 2000.
 
Hi, Linda,

The macro you wanted is below, but first a little rant:

Documents in Word should not have "blank lines," which are really
empty paragraphs. They should be built on styles that contain the
proper amount of Space Before or Space After in their paragraph
formatting. Empty paragraphs cause several kinds of formatting
nastiness, including "Keep with next" formatting of headings that fail
to stay with the following text, undesired space at the tops of pages,
and undesired blank pages at the ends of documents.

However, I recognize that you may be receiving documents from other
people who aren't properly trained, so here is a line counter that
ignores empty paragraphs.

Sub LineCountNotEmpty()
Dim nLines As Long
Dim oRg As Range

Set oRg = ActiveDocument.Range
' replace all multiple paragraph marks
' with single ones
With oRg.Find
.ClearFormatting
.Format = False
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
.Text = "[^13]{2,}"
.Replacement.Text = "^p"
.Execute Replace:=wdReplaceAll
End With

' count remaining lines
nLines = ActiveDocument.ComputeStatistics(wdStatisticLines)

' undo the replacement
ActiveDocument.Undo
MsgBox nLines & " lines"

' collapse selection
Selection.HomeKey wdStory
End Sub
 
HI ALL
I AM A PUTER DUMMIE. I FILL IN THINGS ON AOL WHICH ARE THE SAME THING. CAN I SET UP A MACRO IN WORD TO WORK IN AOL. I WOULD NEED EXPLICIT DIRECTIONS SINCE I AM NOT GOOD AT THIS STUFF. SAY IT ASKS FOR MY DATE OF BIRTH TO BE 01/04/1944. I WOULD LIKE TO BE ABLE TO INSERT WITH A MACRO. HELP THE WIZARDS OF THE INTERNET. THANK YOU. EMAIL ME AT (e-mail address removed).
 
Word's macro language - vba - works in Word, not third party applications.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
Graham Mayor - Word MVP

Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top