Word VS 2010 - Accessing Header/Footer Text By Actual Page Number RRS feed

  • Question

  • Hello.  I'm working on a Word add-in that is supposed to review two versions of a specific document and look for revisions, page by page.  I would like to report the results out showing the descriptive page number of the page that was changed.

    The documents I'm trying to work on have multi-page sections.  The header of each section has a page number field along with other text.  I know how to access the header of a specific section, but when I look at it's range.Text property, it only gives me the actual text of the header on either the first or last page in that section.  If a section's pages range from 2-1 to 2-17 and I try to read the header text from a page in between, it will only show the header text as being the header from the first or last page in the section.  In effect, there's no way I can pass in a "real" page number (14 of 92 for example), and figure out that it may be labeled as page 2-12.

    Does anyone know how to access the specific header text (including the results of fields) by passing in a "real" page number?

    Thanks, I'd appreciate any help or just someone confirming my suspicion that this can't be done.



    Wednesday, March 9, 2011 8:44 PM


  • Hi nautachris,

    Thanks for posting in the MSDN Forum.

    According to your description that your issue a bit more complex. As far as I see, we can get the Page number and the total pages number via access some kind of Word Field type like this snippet:

    And I’m not able to see other manner to get those numbers. As far as I know that in your issue we must compare two documents and find out the different between them. All of these will be handled in the Word Object such as document, rang, section, but I’m not able find the relationship between these and the Word field object.

    I think maybe this is a good sample idea for one code, I will submit it to one code team. Maybe it can be resolved by them.

    Have a good day,


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Bessie Zhao Friday, April 8, 2011 9:27 AM
    Friday, March 11, 2011 2:13 AM