How to get number of pages in certain section in a word?

Posted by Yesi under C# on 6/3/2015 | Points: 10 | Views : 1265 | Status : [Member] | Replies : 1
Hello everyone,

I know how to get number of pages of a whole word. If my Word has more than one sections,and each has their own pages . How to obtain how many pages in certain section using C#? Any ideas ? Thank you .




Responses

Posted by: Bnote on: 6/5/2015 [Member] Starter | Points: 25

Up
0
Down
Using VBA syntax what you need for "section n" is
a. if n
= 1 then you look at

theDocument.sections[1].Range.Information[WdInformation.wdActiveEndPageNumber]

b. if n
> 1 then you establish that section n exists, then look at

theDocument.sections[n].Range.Information[WdInformation.wdActiveEndPageNumber]-
theDocument.sections[n-1].Range.Information[WdInformation.wdActiveEndPageNumber]

and notice that case (b) can return 0 if you have a continuous section break on the last page of section n. I don't know what that would mean in terms of the headers that you would have, but I'd hope it would mean you just had the first page header.

Refered here:

http://stackoverflow.com/questions/12980242/find-the-number-of-pages-in-a-word-document-section-using-interop

Yesi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response