Counting the Lines of Text

P

Phil Galey

Is there a way, through the Word.Application object and it's sub-objects
(e.g. the document object), to determine the number of lines of text in the
document? It seems it's possible to get the count of characters, words,
sentences, and paragraphs. But I need to be able to get the count of lines
of text in the MainTextStory of the document. Thanks.
 
F

fumei via OfficeKB.com

Yes. It is a property of Range.ComputeStatistics.

ActiveDocument.Range.ComputeStatistics(wdStatisticLines)

Warning: it returns a literal answer. Lines. There is NO direct connection
with text.

You asked: "to determine the number of lines of text "

If you have any "empty" paragraphs, they are "lines".

If you change the font size, the number of "lines" will change.

Each cell in a table is counted as a "line". A 3 X 3 table (with no text in
any cell) increases the "line" count by 9.


Counting "lines" in Word is, generally, not a good thing to do. If possible,
count paragraphs. The fact of the matter is you could do a "line" count of a
document - and say get 112 - and then do a line count on the SAME document
but opened in Word on a different computer and get, say 110.

Changing absolutely nothing at all...you can get a different "line" count.
 
P

Phil Galey

The total number of lines, blank or text, is what I needed. Thanks, that
works perfectly.
 

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

Top