Forum Discussion
Section Page Count and Section Pages field Bugs
Posting for Greg Maxey
- I have Microsoft® Word 2019 MSO (Version 2508 Build 16.0.19127.20302) 32-bit.
- There are bugs in program related to accurately returning section page count. To produce, open a new Word document and perform the following:
- Type single short line of text e.g., Hello World.
- Apply an end note to that text.
- Hit the enter key until empty paragraphs push the end note to the very top of the next page.
- In the header enter a {Page} field and a {Section Pages} field. E.g., Page {Page} of {Section Pages} pages
- Update the fields. Look at pages 1 and 2 in the document.
- The Header {Section Pages) field incorrectly returns Page 1 of 1 pages and Page 2 of 1 Pages. The human eye and the {Page} field obviously are correct. The Section Pages field is wrong.
- Run the following macro:
- Sub ScratchMacro()
'A basic Word Macro coded by Gregory K. Maxey
Dim oRng As Range
Set oRng = ActiveDocument.Sections(1).Range
MsgBox ActiveDocument.Sections.Count 'Correct. Word knows the document has 1 section
MsgBox oRng.Information(wdActiveEndSectionNumber) 'Correct. Word knows the range is in that 1 section
MsgBox oRng.Information(wdNumberOfPagesInDocument) 'Correct. Word knows that the document has 2 pages
MsgBox oRng.Information(wdActiveEndPageNumber) 'Bug. Incorrect, should return 2.
lbl_Exit:
Exit Sub
End Sub
2 Replies
- Charles_KenyonBronze Contributor
Hi Doug,
I am not seeing this in MS 365 Classic Word.
Page 2 accurately reflects page 2 for the page count.
My document has an empty paragraph before the endnote on page 2.
The macro returned 1, 1, 2, 2.
My installation of Word requires a Print Preview to update page and numpage fields in the header or footer.
OOPS
I did not follow your instructions.
Without the empty paragraph before the endnote on page 2, SectionPages shows 1.
With the empty paragraph, it shows 2 section pages.
Hi Charles,
Yes, that is the issue - without the empty paragraph at the top of the page before the Endnote.
As Greg was using 2019, it's probably been an issue since Day Dot
However, it does not matter how many pages there are in the Section. If the Endnotes are orphaned at the top of the last page of the Section, the SectionPages field is out by 1
While the 2-page Section issue may be a bit contrived, it is not unrealistic to have a multipage Section where the Endnotes are orphaned - perhaps so that they all appear on the one page.