Programmatically print worksheets
You can print any worksheet in a workbook.
Applies to: The information in this topic applies to document-level projects and VSTO Add-in projects for Excel. For more information, see Features available by Office application and project type.
Print a worksheet in a document-level customization
To print a worksheet
Call the
PrintOut
method ofSheet1
, request two copies, and preview the document before printing.The PrintPreview method enables you to display the specified object in the Print Preview window. The following code assumes you have a Worksheet host item named
Sheet1
.
To preview a page before printing
Call the PrintPreview method of the worksheet.
Print a worksheet in a VSTO Add-in
To print a worksheet
Call the PrintOut method of the active worksheet, request two copies, and preview the document before printing.
The PrintPreview method enables you to display the specified object in the Print Preview window.
To preview a page before printing
Call the PrintPreview method of the active worksheet.