我正在尝试从手动进纸打印 MS Word 文档(以便打印到信封)我发现 Envelope.PrintOut 方法有一个 FeedSource 属性可以帮助定义这个, http: //msdn.microsoft.com /en-us/library/office/ff197594.aspx
但是我很难使用它...这是我用来打印有效文档的功能,如果 fromFeed 为假(常规打印)但如果它为真...当然我尝试了不同的类型WdPaperTray 值...
public void PrintDocument(bool fromFeed)
{
this.doc = this.ap.Documents.Open(this.pathToNewFile, ReadOnly: false, Visible: false);
//if (fromFeed)
// this.doc.Envelope.FeedSource = WdPaperTray.wdPrinterManualFeed;
object copies = "1";
object pages = "";
object range = WdPrintOutRange.wdPrintAllDocument;
object items = WdPrintOutItem.wdPrintDocumentContent;
object pageType = WdPrintOutPages.wdPrintAllPages;
object oTrue = true;
object oFalse = false;
object missing = System.Type.Missing;
this.doc.Activate();
if (fromFeed)
this.doc.Envelope.PrintOut(missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, WdPaperTray.wdPrinterManualFeed, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
else
this.doc.PrintOut(ref oTrue, ref oFalse, ref range, ref missing, ref missing, ref missing,
ref items, ref copies, ref pages, ref pageType, ref oFalse, ref oTrue,
ref missing, ref oFalse, ref missing, ref missing, ref missing, ref missing);
this.ap.Documents.Close(SaveChanges: false, OriginalFormat: false, RouteDocument: false);
}
比我发现这个: http: //msdn.microsoft.com/en-us/library/microsoft.office.interop.word.envelope.feedsource (v=office.11).aspx
它说:“如果您在将信封添加到文档之前使用此属性,则会发生错误”
所以也许我只需要在文件中添加一个信封?但是 MS Word 文档中的信封是什么?
顺便说一句,我正在将其开发为 WPF。并且此时代码抛出此异常:对象值超出范围异常
任何帮助都将受到欢迎。