Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to count no of lines in a particular page of a word document using c#.
Suppose I have a word document. I want to count no of lines in the 3rd page. How shall i do it?
Posted

Richard is right in one point: "There is no concept of lines (...)". There is concept of paragraphs!
Have a look here: WD2000: Macro to Count Number of Paragraphs and Lines in a Document[^]

If you want to count paragraphs on single page, you need to select it first (because the is no functionality to get this portion of information) then you need to use Selection object (Range type) to read this kind of information.


More:
How to select the current page from whole document in Word[^]
Selecting or referring to a page in the Word object model[^]
 
Share this answer
 
A document has no concept of lines until it is laid out on the page and the text adjusted within the header, footer and side margins. So unless you can do that for the entire document you have no way of knowing where the third page actually starts and ends. I am not sure whether Word saves this information in the document, but you could take a look at the Page interface[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900