VBA - Page Numbers

The PageNumbers property of the HeaderFooter object returns a PageNumbers collection, which holds all of the PageNumber objects for that particular header or footer.
In most cases a header (or footer) will contain a single pagenumber object (if any) denoted by PageNumbers(1).
To add a page number to a header or footer
The Add method inserts a text frame containing the page number field into the specified header or footer
The text frame is positioned according to the PageNumberAlignment parameter.
If FirstPage is set to False a page number is not added to the first page


If you want to insert a page number within some other text then you can use the Fields.Add method using the type wdFieldPage



Inserting Page Numbers







Return the Page Number at the current cursor position


Return the number of pages in the active document


The last method is the most reliable, but also the slowest




© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext