Share via


Chart.PrintOut Method

Prints the Chart control.

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

Syntax

'Declaration
Sub PrintOut ( _
    From As Object, _
    To As Object, _
    Copies As Object, _
    Preview As Object, _
    ActivePrinter As Object, _
    PrintToFile As Object, _
    Collate As Object, _
    PrToFileName As Object _
)
void PrintOut(
    Object From,
    Object To,
    Object Copies,
    Object Preview,
    Object ActivePrinter,
    Object PrintToFile,
    Object Collate,
    Object PrToFileName
)

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 (or omitted) 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.
  • PrToFileName
    Type: System.Object
    If PrintToFile is set to true, this argument specifies the name of the file you want to print to.

Remarks

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

Optional Parameters

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

Examples

The following code example creates a Chart and then uses the PrintOut method to print two copies of the chart to a file.

Private Sub PrintChartToFile()
    Me.Range("A1", "A5").Value2 = 22
    Me.Range("B1", "B5").Value2 = 55

    Dim Chart1 As Microsoft.Office.Tools.Excel.Chart = _
        Me.Controls.AddChart(Me.Range("D2", "H12"), "Chart1")

    Chart1.SetSourceData(Me.Range("A1", "B5"), Excel.XlRowCol.xlColumns)
    Chart1.ChartType = Excel.XlChartType.xl3DColumn

    Chart1.PrintOut(Copies:=2, Preview:=True, PrintToFile:=True, _
        Collate:=False)
End Sub
private void PrintChartToFile()
{
    this.Range["A1", "A5"].Value2 = 22;
    this.Range["B1", "B5"].Value2 = 55;

    Microsoft.Office.Tools.Excel.Chart chart1 =
        this.Controls.AddChart(this.Range["D2", "H12"], 
        "chart1");

    chart1.SetSourceData(this.Range["A1", "B5"], 
        Excel.XlRowCol.xlColumns);
    chart1.ChartType = Excel.XlChartType.xl3DColumn;

    chart1.PrintOut(missing, missing, 2, true, missing, 
        true, false, missing);
}

.NET Framework Security

See Also

Reference

Chart Interface

Microsoft.Office.Tools.Excel Namespace