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. 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)
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
Breaks
Returns a Breaks collection that represents the breaks on a page.
The Breaks collection includes page, column, and section breaks. Use the Breaks collection and the related objects and properties to programmatically define page layout in a document.
Dim objBreaks As Breaks
Set objBreaks = ActiveDocument.ActiveWindow _
.Panes(1).Pages(1).Breaks
EnhMetaFileBits
Returns a Variant that represents a picture representation of how a page of text appears.
The EnhMetaFileBits property returns an array of bytes, which can be used with the Microsoft Windows 32 Application Programming Interface from within the Microsoft Visual Basic or Microsoft C++ development environment.
Dim varEnhMetaFileBits As Variant
varEnhMetaFileBits = ActiveWindow.ActivePane.Pages(1).EnhMetaFileBits
Height
Returns a Long that represents the height of a page, in pixels.
The Top and Left properties of the Page object always return 0 (zero) indicating the upper-left corner of the page. The Height and Width properties return the height and width in points (72 points = 1 inch) of the paper size specified in the Page Setup dialog box or through the PageSetup object. For example, for an 8-1/2 by 11 inch page in portrait mode, the Height property returns 792 and the Width property returns 612. All four of these properties are read-only.
Dim lngHeight As Long
lngHeight = ActiveWindow.ActivePane.Pages(1).Height
Left
Returns a Long that represents the left edge of the page.
The Top and Left properties of the Page object always return 0 (zero) indicating the upper-left corner of the page. The Height and Width properties return the height and width in points (72 points = 1 inch) of the paper size specified in the Page Setup dialog or through the PageSetup object. For example, for an 8-1/2 by 11 inch page in portrait mode, the Height property returns 792 and the Width property returns 612. All four of these properties are read-only.
Dim lngLeft As Long
lngLeft = ActiveWindow.ActivePane.Pages(1).Left
Rectangles
Returns a Rectangles collection that represents a portion of text or graphics in a page in a document.
Use the Rectangles collection and related objects and properties for programmatically defining page layout in a document. Rectangles correspond to portions of text or graphics on a page in a document.
Dim objRectangles As Rectangles
Set objRectangles = ActiveDocument.ActiveWindow _
.Panes(1).Pages(1).Rectangles
Top
Returns a Long that represents the top edge of the page.
The Top and Left properties of the Page object always return 0 (zero) indicating the upper-left corner of the page. The Height and Width properties return the height and width in points (72 points = 1 inch) of the paper size specified in the Page Setup dialog or through the PageSetup object. For example, for an 8-1/2 by 11 inch page in portrait mode, the Height property returns 792 and the Width property returns 612. All four of these properties are read-only.
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.
The Top and Left properties of the Page object always return 0 (zero) indicating the upper-left corner of the page. The Height and Width properties return the height and width in points (72 points = 1 inch) of the paper size specified in the Page Setup dialog or through the PageSetup object. For example, for an 8-1/2 by 11 inch page in portrait mode, the Height property returns 792 and the Width property returns 612. All four of these properties are read-only.
Dim lngWidth As Long
lngWidth = ActiveWindow.ActivePane.Pages(1).Width