Class VPageBreak (Excel VBA)
The class VPageBreak represents a vertical page break. To use a VPageBreak class variable it first needs to be instantiated, for example
For Each
Here is an example of processing the VPageBreak items in a collection.
Dim shts As Sheets: Set shts =
Dim vpgbr As VPageBreak
For Each vpgbr In shts.VPageBreaks
With vpgbr
End With
Next vpgbr
Delete
Deletes the object.
Dim vpgbr As VPageBreak: Set vpgbr =
vpgbr.Delete
DragOff
Drags a page break out of the print area.
This method exists primarily for the macro recorder. You can use the Delete method to delete a page break in Visual Basic.
DragOff (Direction, RegionIndex)
Dim lngRegionIndex As Long: lngRegionIndex = 1
Dim vpgbr As VPageBreak: Set vpgbr =
vpgbr.DragOff Direction:=xlDown, RegionIndex:=lngRegionIndex
Arguments
The following arguments are required:
Direction (XlDirection) - The direction in which the page break is dragged.
Possible values are
xlDown | Down. |
xlToLeft | To left. |
xlToRight | To right. |
xlUp | Up. |
RegionIndex (Long) - The print-area region index for the page break (the region where the mouse pointer is located when the mouse button is pressed if the user drags the page break). If the print area is contiguous, there's only one print region. If the print area is discontiguous, there's more than one print region.
Extent
Returns the type of the specified page break: full-screen or only within a print area. Can be either of the following XlPageBreakExtent constants: xlPageBreakFull or xlPageBreakPartial. Possible return values are xlPageBreakFull - Full screen, xlPageBreakPartial - Only within print area.
Dim vpgbr As VPageBreak: Set vpgbr =
Dim xpbExtent As XlPageBreakExtent
xpbExtent = vpgbr.Extent
Location
Dim vpgbr As VPageBreak: Set vpgbr =
vpgbr.Location =
Type
Returns or sets an XlPageBreak value that represents the page break type. Possible return values are xlPageBreakAutomatic - Excel will automatically add page breaks, xlPageBreakManual - Page breaks are manually inserted, xlPageBreakNone - Page breaks are not inserted on the worksheet.
Dim vpgbr As VPageBreak: Set vpgbr =
vpgbr.Type = xlPageBreakAutomatic