Version

InsertPageBreak(WorksheetCell) Method

Inserts a horizontal and/or vertical page break before the specified cell.
Syntax
'Declaration
 
Public Overloads Sub InsertPageBreak( _
   ByVal cell As WorksheetCell _
) 
public void InsertPageBreak( 
   WorksheetCell cell
)

Parameters

cell
The cell at which to insert the page break(s).
Exceptions
ExceptionDescription
System.ArgumentNullExceptionOccurs when cell is null.
System.ArgumentExceptionOccurs when cell is at the top-left corner of the Worksheet.
Remarks

If the cell is not contained in one of the print areas in the PrintAreas collection, the page breaks added will be as follows: If the cell is at the top-left corner of the Worksheet, an exception will be thrown. If the cell is on the left edge of the Worksheet, a horizontal page break will be inserted above the cell. If the cell is on the top edge of the Worksheet, a vertical page break will be inserted to the left of the cell. If the cell is anywhere else in the Worksheet, a horizontal page break will be inserted above the cell and a vertical page break will be inserted to the left of the cell.

If the cell is contained in one of the print areas in the PrintAreas collection, the page breaks added will be as follows: If the cell is at the top-left corner of the print area, no page breaks will be inserted. If the cell is on the left edge of the print area, a horizontal page break will be inserted above the cell. If the cell is on the top edge of the print area, a vertical page break will be inserted to the left of the cell. If the cell is anywhere else in the print area, a horizontal page break will be inserted above the cell and a vertical page break will be inserted to the left of the cell.

When page breaks are inserted in a print area, they will only extend to the edges of the print area.

Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also