Hi,


I am genrating a word document using VB.net . I am first creating few sections of word document and later merging them into one final main document. to remove blank pages in each section document i have function to remove blank pages in case of any. In the blank page funtion i first calculate the number of pages in section and then later go through each page to see if its a blank page and then delete it.

The issue now is that i have a section word document which has 2 pages in it where the data exactly comes till the end of first page and the secong page only has a carraige return character and a page break. Ideally my blank page function should remove this second page as it contains no data. The main issue now is that the number of pages in this section document is calculated as 1 instead of 2. Due to this 2nd page remains blank.

Below code is used for no. of pages calcualtion.

PWordApp.Application.ScreenUpdating = true
PWordApp.Selection.WholeStory()
PWordApp.Selection.Font.Hidden = false

MaxPages = PWordApp.Selection.Information(Word.WdInformation. wdNumberOfPagesInDocument)

or i also tried below one.
MaxPages = PWordDoc.ComputeStatistics(Word.WdStatistic.wdStat isticPages)




Please help to find out actual no. of pages in a document correctly.