Worksheet.PrintOut 方法 (2007 system)

更新:2007 年 11 月

打印工作表。

命名空间:  Microsoft.Office.Tools.Excel
程序集:  Microsoft.Office.Tools.Excel.v9.0(在 Microsoft.Office.Tools.Excel.v9.0.dll 中)

语法

声明
Public 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 _
)
用法
Dim instance As Worksheet
Dim From As Object
Dim To As Object
Dim Copies As Object
Dim Preview As Object
Dim ActivePrinter As Object
Dim PrintToFile As Object
Dim Collate As Object
Dim PrToFileName As Object

instance.PrintOut(From, To, Copies, Preview, _
    ActivePrinter, PrintToFile, Collate, _
    PrToFileName)
public void PrintOut(
    Object From,
    Object To,
    Object Copies,
    Object Preview,
    Object ActivePrinter,
    Object PrintToFile,
    Object Collate,
    Object PrToFileName
)

参数

  • From
    类型:System.Object

    要打印的第一页的页码。如果省略此参数,则打印从第一页开始。

  • To
    类型:System.Object

    要打印的最后一页的页码。如果省略此参数,则打印完最后一页后停止打印。

  • Copies
    类型:System.Object

    要打印的份数。如果省略此参数,则打印一份副本。

  • Preview
    类型:System.Object

    如果让 Microsoft Office Excel 在打印对象之前调用打印预览,则为 true;如果立即打印对象,则为 false(或者省略)。

  • ActivePrinter
    类型:System.Object

    设置活动打印机的名称。

  • PrintToFile
    类型:System.Object

    为 true 时打印到文件。如果未指定 PrToFileName,则 Excel 提示用户输入输出文件的名称。

  • Collate
    类型:System.Object

    如果为 true,则逐份打印多个副本。

  • PrToFileName
    类型:System.Object

    如果 PrintToFile 设置为 true,则此参数指定要打印到的文件的名称。

备注

From 和 To 的说明中的“页”是指打印页,而不是工作表中的全部页。

可选参数

有关可选参数的信息,请参见了解 Office 解决方案中的可选参数

示例

下面的代码示例使用 PrintOut 方法将当前工作表打印到用户指定的文件名。

此示例针对的是文档级自定义项。

Private Sub PrintToFile()
    ' Make sure the worksheet has some data before printing.
    Me.Range("A1").Value2 = "123"
    Me.PrintOut(1, 2, 1, False, PrintToFile:=True)
End Sub
private void PrintToFile()
{
    // Make sure the worksheet has some data before printing.
    this.Range["A1", missing].Value2 = "123";
    this.PrintOut(1, 2, 1, false, missing, true, false, missing);
}

权限

另请参见

参考

Worksheet 类

Worksheet 成员

Microsoft.Office.Tools.Excel 命名空间