Class Page (Excel VBA)

The class Page represents a page in a workbook. Use the Page object and the related methods and properties for programmatically defining page layout in a workbook.

Item

To use a Page class variable it first needs to be instantiated, for example

Dim pag as Page
Set pag = ActiveChart.PageSetup.Pages(Index:=1)

The following procedures can be used to set variables of type Page: Pages.Item, PageSetup.EvenPage and PageSetup.FirstPage.

For Each

Here is an example of processing the Page items in a collection.

Dim pag As Page
For Each pag In ActiveChart.PageSetup.Pages
	
Next pag

CenterFooter

Specifies a picture or text to be center-aligned in the page footer.

Dim hfrCenterFooter As HeaderFooter
Set hfrCenterFooter = ActiveChart.PageSetup.Pages(1).CenterFooter

CenterHeader

Specifies a picture or text to be center-aligned in the page header.

Dim hfrCenterHeader As HeaderFooter
Set hfrCenterHeader = ActiveChart.PageSetup.Pages(1).CenterHeader

LeftFooter

Specifies a picture or text to be left-aligned in the page footer.

Dim hfrLeftFooter As HeaderFooter
Set hfrLeftFooter = ActiveChart.PageSetup.Pages(1).LeftFooter

LeftHeader

Specifies a picture or text to be left-aligned in the page header.

Dim hfrLeftHeader As HeaderFooter
Set hfrLeftHeader = ActiveChart.PageSetup.Pages(1).LeftHeader

RightFooter

Specifies a picture or text to be right-aligned in the page footer.

Dim hfrRightFooter As HeaderFooter
Set hfrRightFooter = ActiveChart.PageSetup.Pages(1).RightFooter

RightHeader

Specifies a picture or text to be right-aligned in the page header.

Dim hfrRightHeader As HeaderFooter
Set hfrRightHeader = ActiveChart.PageSetup.Pages(1).RightHeader

Pages.Count

Returns the number of objects in the collection.

Dim lngCount As Long
lngCount = ActiveChart.PageSetup.Pages.Count

Pages.Item

Returns a Page object that represents a collection of pages in a workbook.

Item (Index)

Index: Index value of the page.

Dim pagItem As Page
Set pagItem = ActiveChart.PageSetup.Pages(Index:=1)