Print related procedures in class Worksheet (Excel VBA)

This page presents procedures from class Worksheet related to the theme Print: Sheets.HPageBreaks, Sheets.PrintOut, Sheets.PrintPreview, Sheets.VPageBreaks, DisplayPageBreaks, HPageBreaks, PageSetup, PrintedCommentPages, PrintOut, PrintPreview, ResetAllPageBreaks, VPageBreaks, Worksheets.HPageBreaks, Worksheets.PrintOut, Worksheets.PrintPreview and Worksheets.VPageBreaks

Sheets.HPageBreaks

Returns an HPageBreaks collection that represents the horizontal page breaks on the sheet.

There is a limit of 1026 horizontal page breaks per sheet.

Dim hpbsHPageBreaks As HPageBreaks
Set hpbsHPageBreaks = Charts.HPageBreaks

Sheets.PrintOut

Prints the object.

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

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

ActiveSheet.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, 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

IgnorePrintAreas (Boolean) - True to ignore print areas and print the entire object.

Sheets.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.

Worksheets("Sheet1").PrintPreview

Sheets.VPageBreaks

Returns a VPageBreaks collection that represents the vertical page breaks on the sheet.

Dim vpbsVPageBreaks As VPageBreaks
Set vpbsVPageBreaks = Charts.VPageBreaks

DisplayPageBreaks

True if page breaks (both automatic and manual) on the specified worksheet are displayed.

You can't set this property if you don't have a printer installed.

ActiveSheet.DisplayPageBreaks = True

HPageBreaks

Returns an HPageBreaks collection that represents the horizontal page breaks on the sheet.

There is a limit of 1,026 horizontal page breaks per sheet.

Dim hpbsHPageBreaks As HPageBreaks
Set hpbsHPageBreaks = ActiveSheet.HPageBreaks

PageSetup

Returns a PageSetup object that contains all the page setup settings for the specified object.

Dim pspPageSetup As PageSetup
Set pspPageSetup = ActiveSheet.PageSetup

PrintedCommentPages

Returns the number of comment pages that will be printed for the current worksheet.

The PrintedCommentPages property only returns a number greater than zero if the Comments setting on the Sheet tab of the Page Setup dialog box is set to At end of sheet. This property returns zero if the sheet is a Chart sheet or an MS Excel 5.0 Dialog sheet.

Dim lngPrintedCommentPages As Long
lngPrintedCommentPages = ActiveSheet.PrintedCommentPages

PrintOut

Prints the object.

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

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

ActiveSheet.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, 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

IgnorePrintAreas (Boolean) - True to ignore print areas and print the entire object.

PrintPreview

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

PrintPreview (EnableChanges)

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

ActiveSheet.PrintPreview

ResetAllPageBreaks

Resets all page breaks on the specified worksheet.

ActiveSheet.ResetAllPageBreaks

VPageBreaks

Returns a VPageBreaks collection that represents the vertical page breaks on the sheet.

Dim vpbsVPageBreaks As VPageBreaks
Set vpbsVPageBreaks = ActiveSheet.VPageBreaks

Worksheets.HPageBreaks

Returns an HPageBreaks collection that represents the horizontal page breaks on the sheet.

There is a limit of 1026 horizontal page breaks per sheet.

Dim wrks As Worksheets: Set wrks = Worksheets(1)
Dim hpbsHPageBreaks As HPageBreaks
Set hpbsHPageBreaks = wrks.HPageBreaks

Worksheets.PrintOut

Prints the object.

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

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

ActiveSheet.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

IgnorePrintAreas (Boolean) - True to ignore print areas and print the entire object.

Worksheets.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.

Worksheets("Sheet1").PrintPreview

Worksheets.VPageBreaks

Returns a VPageBreaks collection that represents the vertical page breaks on the sheet.

Dim wrks As Worksheets: Set wrks = Worksheets(1)
Dim vpbsVPageBreaks As VPageBreaks
Set vpbsVPageBreaks = wrks.VPageBreaks