Class VPageBreak (Excel VBA)
The class VPageBreak represents a vertical page break.
Set
To use a VPageBreak class variable it first needs to be instantiated, for example
Dim rngBefore As Range: Set rngBefore =
Dim chrs As Charts: Set chrs =
Dim vpgbr As VPageBreak
Set vpgbr = chrs.VPageBreaks.Add(Before:=rngBefore)
The following procedures can be used to set variables of type VPageBreak: VPageBreaks.Item, VPageBreaks.Add, Charts.VPageBreaks, Sheets.VPageBreaks, Sheets.VPageBreaks, Worksheet.VPageBreaks and Worksheets.VPageBreaks
For Each
Here is an example of processing the VPageBreak items in a collection.
Dim chrs As Charts: Set chrs =
Dim vpgbrVPageBreak As VPageBreak
For Each vpgbrVPageBreak In chrs.VPageBreaks
Next vpgbrVPageBreak
Delete
Deletes the object.
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.
Syntax : expression.DragOff (Direction, RegionIndex)
ActiveSheet.VPageBreaks(1).DragOff xlToRight, 1
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 Values are xlPageBreakFull - Full screen, xlPageBreakPartial - Only within print area.For Each pb in Worksheets(1).HPageBreaks
If pb.Extent = xlPageBreakFull Then
cFull = cFull + 1
Else
cPartial = cPartial + 1
End If
Next
MsgBox cFull & " full-screen page breaks, " & cPartial & _
" print-area page breaks"
Parent
Returns the parent object for the specified object.
Type
Returns or sets an XlPageBreak value that represents the page break type.
Possible Values are xlPageBreakAutomatic - Excel will automatically add page breaks, xlPageBreakManual - Page breaks are manually inserted, xlPageBreakNone - Page breaks are not inserted on the worksheet.VPageBreaks.Add
Adds a vertical page break.
Syntax : expression.Add (Before)
Before: A Range object. The range to the left of which the new page break will be added.
With Worksheets(1)
.HPageBreaks.Add .Range("F25")
.VPageBreaks.Add .Range("F25")
End With
VPageBreaks.Count
Returns a Long value that represents the number of objects in the collection.
VPageBreaks.Item
Returns a single VPageBreak object from the collection.
Syntax : expression.Item (Index)
Index: The index number of the object.
Worksheets(1).VPageBreaks.Item(1).Location = .Range("e5")
VPageBreaks.Parent
Returns the parent object for the specified object. Read-only.