Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback. Insert a Current Page Number marker for x, and insert the Last Page Number text variable for y (choose Type > Text Variables > Insert Variable > Last Page Number).
PageNumbers Collection Object Support and feedback The Page X of Y text is inserted into the header and the main spreadsheet automatically becomes active again. Select of from the drop-down menu. WdAlignPageNumberCenter, FirstPage:= True) You can also insert Page X of Y into the header by clicking the Header button in the Header & Footer section of the Design tab. Set myPgNum = ActiveDocument.Sections(1) _ This example creates and formats page numbers in the header for the active document. PageNumberAlignment:=wdAlignPageNumberLeft, _ Footers(wdHeaderFooterPrimary).PageNumbers.Add _ This example adds a page number to the primary footer in the first section of the active document.
If the LinkToPrevious property for the HeaderFooter object is set to True, the page numbers will continue sequentially from one section to next throughout the document. Y is the total number of pages in the document.
HOW TO ADD PAGE X OF Y IN WORD HOW TO
Sometimes people ask: How to display both 'Page X of Y Pages' and 'Page X of Z Pages' in the header/footer of a document Where X is the page number referenced to Y or Z. If this argument is omitted, the setting is controlled by the DifferentFirstPageHeaderFooter property. The Word MVP FAQ site has several helpful articles on page numbering: Numbering FAQs. If FirstPage is set to False, a page number isn't added to the first page. Parameters NameĬan be any WdPageNumberAlignment constant.įalse to make the first-page header and the first-page footer different from the headers and footers on all subsequent pages in the document. A variable that represents a PageNumbers object. Add ( PageNumberAlignment, FirstPage)Įxpression Required. Insert hyperlink: Ctrl + L: Left alignment: Ctrl + Left Arrow: Jump word to left: Ctrl + M: Increase indent or tab: Ctrl + N: Create a new document: Ctrl + O: Open an existing document: Ctrl + P: Go to print options: Ctrl + Page Down: Move to next browse object set in browse options: Ctrl + Page Up: Move to previous browse object set inn browse.
Returns a PageNumber object that represents page numbers added to a header or footer in a section.