加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

如何:Word 将文档发送到打印机

(2008-07-18 13:56:35)
标签:

it

可以使用 PrintOut 方法将 Microsoft Office Word 文档(或文档的一部分)发送到打印机。可以从 ApplicationDocument 对象调用 PrintOut()

打印文档

  • 下面的代码用所有默认选项打印活动文档:
    ThisDocument.PrintOut()
    

PrintOut 方法有多个可选参数,允许您微调打印文档的方式,下表概括了这些参数。

参数 说明
Background 设置为 True 可允许在 Word 打印文档时继续处理。
Append OutputFileName 参数一起使用。设置为 True 可将指定的文档名称追加到由 OutputFileName 参数指定的文件名后。设置为 False 将重写 OutputFileName 的内容。
Range 页面范围。可以为任何 WdPrintOutRange 枚举:wdPrintAllDocumentwdPrintCurrentPagewdPrintFromTowdPrintRangeOfPageswdPrintSelection
OutputFileName 如果 PrintToFile 为 True,此参数指定输出文件的路径和文件名。
From Range 设置为 wdPrintFromTo 时的起始页码。
To Range 设置为 wdPrintFromTo 时的结束页码。
Item 要打印的项。可以是任何 WdPrintOutItem 枚举:wdPrintAutoTextEntrieswdPrintCommentswdPrintDocumentContentwdPrintKeyAssignmentswdPrintPropertieswdPrintStyles
Copies 要打印的份数。
Pages 要打印的页码和页码范围,由逗号分隔。例如,“2, 6-10”意为打印第 2 页和第 6、7、8、9、10 页。
PageType 要打印的页面的类型。可以是任何 WdPrintOutPages 常量:wdPrintAllPageswdPrintEvenPagesOnlywdPrintOddPagesOnly
PrintToFile 设置为 True 可将打印机指令发送到文档。确保使用 OutputFileName 指定一个文件名。
Collate 打印一个文档的多个副本时使用此参数。设置为 True 则在打印下一个副本前将打印此文档的所有页面。
FileName 仅适用于 Application 对象。要打印的文档的路径和文件名。如果不用此参数,Word 将打印活动文档。
ManualDuplexPrint 设置为 True 可在打印机上没有双面打印装置的情况下打印双面文档。

常用的 PrintOut 参数。

打印活动文档的第一页

  • 下面的过程打印活动文档的第一页:

// C#
internal void PrintOutDoc()
{
    object myTrue = true;
    object myFalse = false;
    object missingValue = Type.Missing;
    object range = Word.WdPrintOutRange.wdPrintCurrentPage;
    object items = Word.WdPrintOutItem.wdPrintDocumentContent;
    object copies = "1";
    object pages = "1";
    object pageType = Word.WdPrintOutPages.wdPrintAllPages;

    ThisDocument.PrintOut(ref myTrue, ref myFalse, ref range,
        ref missingValue, ref missingValue, ref missingValue,
        ref items, ref copies, ref pages, ref pageType, ref myFalse,
        ref myTrue, ref missingValue,  ref myFalse, ref missingValue,
        ref missingValue, ref missingValue, ref missingValue);
}

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有