http://qs321.pair.com?node_id=334734


in reply to Re: How to get MS-Word Page count and line count?
in thread How to get MS-Word Page count and line count?

Try this code. It's untested, and I never get it right if you need the {} around Count or not.

my $doc = $word->Application->Selection; # Selection can be the entire doc or refined to a sub-set of text # It is easier to use the functions that exist in word to do the work. $num_paragraphs = $selection->Paragraphs->{Count}; $num_words = $selection->Words->{Count}; $num_chars = $selection->Characters->{Count}; $num_pages = $selection->pagenumbers->{Count};
As for the line count, your going to have a problems here. Word probably does not mark new lines as you would expect. It automaticly wraps based on the available space. So instead of looking for line count you could do Sentence->Count.