How to get page number?

后端 未结 3 867
情歌与酒
情歌与酒 2021-01-19 05:13

I have this code:

Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
object nullobj = System.Reflection.Missing         


        
3条回答
  •  一向
    一向 (楼主)
    2021-01-19 06:01

    For me, the ComputeStatistics function would give me a higher number than the actual number of pages so that didn't work for me.

    I used range.get_Information()

    var range = doc.Range().GoTo(WdGoToItem.wdGoToPage, WdGoToDirection.wdGoToLast);
    var numPages = range.get_Information(WdInformation.wdActiveEndPageNumber);
    

    The first line gets the range on the last page of the document. The second line gets the page where the range is.

提交回复
热议问题