Print related procedures in class Range (Excel VBA)

This page presents procedures from class Range related to the theme Print: PageBreak, PrintOut and PrintPreview

PageBreak

Returns or sets the location of a page break. Can be one of the following XlPageBreak constants: xlPageBreakAutomatic, xlPageBreakManual, or xlPageBreakNone.

This property can return the location of either automatic or manual page breaks, but it can only set the location of manual breaks (it can only be set to xlPageBreakManual or xlPageBreakNone). To remove all manual page breaks on a worksheet, set Cells.PageBreak to xlPageBreakNone.

Worksheets("Sheet1").Rows(25).PageBreak = xlPageBreakManual

PrintOut

Prints the object.

"Pages" in the descriptions of From and To refers to printed pages, and not to overall pages in the sheet or workbook.

PrintOut (From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName)

ActiveCell.PrintOut

Arguments

The following arguments are optional

From (Long) - The number of the page at which to start printing. If this argument is omitted, printing starts at the beginning.

To (Long) - The number of the last page to print. If this argument is omitted, printing ends with the last page.

Copies (Long) - The number of copies to print. If this argument is omitted, one copy is printed.

Preview (Boolean) - True to have Microsoft Excel invoke print preview before printing the object. False (or omitted) to print the object immediately.

ActivePrinter (String) - Sets the name of the active printer.

PrintToFile (Boolean) - True to print to a file. If PrToFileName is not specified, Microsoft Excel prompts the user to enter the name of the output file.

Collate (Boolean) - True to collate multiple copies.

PrToFileName - If PrintToFile is set to True, this argument specifies the name of the file that you want to print to

PrintPreview

Shows a preview of the object as it would look when printed.

PrintPreview (EnableChanges)

EnableChanges: Pass a Boolean value to specify if the user can change the margins and other page setup options available in print preview.

ActiveCell.PrintPreview