Class Page (Word VBA)

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

Set

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

Dim pag as Page
Set pag = ActiveWindow.ActivePane.Pages(Index:=1)

The following procedures can be used to set variables of type Page: Pages.Item and Pane.Pages

For Each

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

Dim pag As Page
For Each pag In ActiveWindow.ActivePane.Pages
	
Next pag

Properties

Breaks returns a Breaks collection that represents the breaks on a page.

Dim brksBreaks As Breaks
Set brksBreaks = ActiveWindow.ActivePane.Pages(1).Breaks

EnhMetaFileBits returns a Variant that represents a picture representation of how a page of text appears.

Dim varEnhMetaFileBits As Variant
varEnhMetaFileBits = ActiveWindow.ActivePane.Pages(1).EnhMetaFileBits

Height returns a Long that represents the height of a page, in pixels.

Dim lngHeight As Long
lngHeight = ActiveWindow.ActivePane.Pages(1).Height

Left returns a Long that represents the left edge of the page.

Dim lngLeft As Long
lngLeft = ActiveWindow.ActivePane.Pages(1).Left

Parent returns an object that represents the parent object of the specified Page object.

Dim objParent As Object
Set objParent = ActiveWindow.ActivePane.Pages(1).Parent

Rectangles returns a Rectangles collection that represents a portion of text or graphics in a page in a document.

Dim rctsRectangles As Rectangles
Set rctsRectangles = ActiveWindow.ActivePane.Pages(1).Rectangles

Top returns a Long that represents the top edge of the page.

Dim lngTop As Long
lngTop = ActiveWindow.ActivePane.Pages(1).Top

Width returns a Long that represents the width, in points, of the paper defined in the Page Setup dialog box.

Dim lngWidth As Long
lngWidth = ActiveWindow.ActivePane.Pages(1).Width

Pages.Count returns a Long that represents the number of pages in the collection.

Dim lngCount As Long
lngCount = ActiveWindow.ActivePane.Pages.Count

Pages.Parent returns an object that represents the parent object of the specified Pages object.

Dim objParent As Object
Set objParent = ActiveWindow.ActivePane.Pages.Parent