Share via

Identifying Page Numbers in Header or Footer of a Word Document Programmatically

Anonymous
2021-02-09T20:39:22+00:00

I am not very farmiliar with how Headers and Footers work, but here is my question.  We have a group of word document files that have been created from other users.  We need to read these documents programmatically through VS to determine if they have a page number on each page either in the header or footer.  And if they have specific text either in the header or footer.  I have been searching around the web but have not been able to find related to this issue.  If this is not do able, one approach we were thinking of doing is to have our process add a page number if there is a page numbe or not.  If we do this and there is additional text in the header or footer will that text be removed?

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Charles Kenyon 167.5K Reputation points Volunteer Moderator
    2021-02-09T22:06:53+00:00
    1. Word does not have pages, as such, even though it prints and displays them. They are not part of the structure of a Word document.
    2. Headers and footers are multi-page constructs even though they may not appear on more than one page.
    3. To approach this, you are going to have to understand how Word uses page numbers.
    4. Page numbers are fields, specifically, a PAGE field.
    5. They are normally in a header or footer.
    6. Each section in Word will have the structure for three headers and three footers.
    7. A single section may span many pages or be on a part of a page. / A single page can contain multiple sections.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Charles Kenyon 167.5K Reputation points Volunteer Moderator
    2021-02-09T22:12:51+00:00

    I am not very farmiliar with how Headers and Footers work, but here is my question.  We have a group of word document files that have been created from other users.  We need to read these documents programmatically through VS to determine if they have a page number on each page either in the header or footer.  And if they have specific text either in the header or footer.  I have been searching around the web but have not been able to find related to this issue.  If this is not do able, one approach we were thinking of doing is to have our process add a page number if there is a page numbe or not.  If we do this and there is additional text in the header or footer will that text be removed?

    Will your adding a page number delete existing text in a header or footer?

    It depends on how you do it. The building blocks in Word do this. Editing the header or footer does not unless intentionally.

    Was this answer helpful?

    0 comments No comments