Export (0) Print
Expand All
Expand Minimize

WorksheetBase.PrintOutEx Method

Prints the worksheet.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

public void PrintOutEx(
	Object from,
	Object to,
	Object copies,
	Object preview,
	Object activePrinter,
	Object printToFile,
	Object collate,
	Object prToFileName,
	Object ignorePrintAreas
)

Parameters

from
Type: System.Object

The number of the page at which to start printing. If this argument is omitted, printing starts at the beginning.

to
Type: System.Object

The number of the last page to print. If this argument is omitted, printing ends with the last page.

copies
Type: System.Object

The number of copies to print. If this argument is omitted, one copy is printed.

preview
Type: System.Object

true to have Microsoft Office Excel invoke print preview before printing the object. false to print the object immediately.

activePrinter
Type: System.Object

Sets the name of the active printer.

printToFile
Type: System.Object

true to print to a file. If PrToFileName is not specified, Excel prompts the user to enter the name of the output file.

collate
Type: System.Object

true to collate multiple copies.

prToFileName
Type: System.Object

If PrintToFile is set to true, this argument specifies the name of the file you want to print to.

ignorePrintAreas
Type: System.Object

true to ignore print areas and print the entire workbook; otherwise, false.

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

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

The following code example uses the PrintOutEx method to print two collated copies of the first two pages of the worksheet to the default printer. To run this code example, your workbook must contain a worksheet named Sheet1 with some data.

This example is for a document-level customization.

private void PrintWorksheet()
{
    Microsoft.Office.Tools.Excel.Worksheet mySheet = Globals.Sheet1.Base;

    mySheet.PrintOutEx(
        1,
        2,
        2,
        false,

        false,
        true,

        true);
}

Show:
© 2015 Microsoft