none
how to get page number of a word document RRS feed

  • Question

  • please tell me how to get the page number of a page in a word document using c#.

    Thanks in advance.


    -Madura Shantha- Code as if the next guy to maintain your code is a homicidal maniac who knows where you live.
    Tuesday, March 29, 2011 4:15 AM

Answers

All replies

  • Hi madura,

    It's in the Information property. Here's a link.

    http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.selection.information.aspx

    I'm not sure how to convert this to C# but this is how it looks in VB

    wdoc.Selection.Information(Microsoft.Office.Interop.Word.

    WdInformation

    .wdActiveEndAdjustedPageNumber)

    wdoc.Selection.Information(Microsoft.Office.Interop.Word.

    WdInformation.wdActiveEndPageNumber)

    wdoc is my var for the active Word document.

    Hope this helps


    Regards
    • Marked as answer by madura shantha Wednesday, March 30, 2011 4:28 AM
    Tuesday, March 29, 2011 2:06 PM
  • Thanks Rich,

    in C# it was,

    selection.get_Information(Microsoft.Office.Interop.Word.WdInformation.wdActiveEndPageNumber)

    Thanks a lot.


    -Madura Shantha- Code as if the next guy to maintain your code is a homicidal maniac who knows where you live.
    Wednesday, March 30, 2011 4:32 AM