Поделиться через


How to: Print Worksheets

You can print any worksheet in a workbook.

Applies to: The information in this topic applies to document-level projects and application-level projects for Excel 2007 and Excel 2010. For more information, see Features Available by Office Application and Project Type.

Printing a Worksheet in a Document-Level Customization

To print a worksheet

  • Call the PrintOut method of Sheet1, request two copies, and preview the document before printing.

    Globals.Sheet1.PrintOut(From:=1, To:=1, Copies:=2, Preview:=True)
    
    Globals.Sheet1.PrintOut(1, 1, 2, true, missing, missing, missing, missing);
    

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.

    Globals.Sheet1.PrintPreview()
    
    Globals.Sheet1.PrintPreview(missing);
    

Printing a Worksheet in an Application-Level Add-In

To print a worksheet

  • Call the _Worksheet.PrintOut method of the active worksheet, request two copies, and preview the document before printing.

    CType(Application.ActiveSheet, Excel.Worksheet).PrintOut _
       (From:=1, To:=1, Copies:=2, Preview:=True)
    
    ((Excel.Worksheet)Application.ActiveSheet).PrintOut
        (1, 1, 2, true, missing, missing, missing, missing);
    

The _Worksheet.PrintPreview method enables you to display the specified object in the Print Preview window.

To preview a page before printing

  • Call the _Worksheet.PrintPreview method of the active worksheet.

    CType(Application.ActiveSheet, Excel.Worksheet).PrintPreview()
    
    ((Excel.Worksheet)Application.ActiveSheet).PrintPreview(missing);
    

See Also

Tasks

How to: Check Spelling in Worksheets

How to: Send Workbooks by E-Mail Programmatically

Concepts

Working with Worksheets

Worksheet Host Item

Global Access to Objects in Office Projects

Optional Parameters in Office Solutions