我使用C#和Word Interop来自动化邮件合并。我想使用默认选项将每个合并文档打印到默认打印机,但不希望每次都显示打印选项对话框。我怎样才能做到这一点?当我在客户端计算机上尝试此代码时,将在调用PrintOut方法时显示打印选项对话框。这是我的代码:
Word.Application oWord = new Word.Application();
oWord.Visible = false;
Word.Document oWordDoc = new Word.Document();
object oTemplatePath = Path.Combine(baseDir, fileName);
oWordDoc = oWord.Documents.Add((ref oTemplatePath, ref oMissing, ref oMissing, ref oMissing);
object copies = "1";
object pages = "";
object range = Word.WdPrintOutRange.wdPrintAllDocument;
object items = Word.WdPrintOutItem.wdPrintDocumentContent;
object pageType = Word.WdPrintOutPages.wdPrintAllPages;
object oTrue = true;
object oFalse = false;
oWordDoc.PrintOut(ref oTrue, ref oFalse, ref range, ref oMissing, ref oMissing, ref oMissing, ref items, ref copies, ref pages, ref pageType, ref oFalse, ref oTrue, ref oMissing, ref oFalse, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
答案 0 :(得分:0)
我正在使用这个,它适用于word文档。
Process p = new Process();
p.StartInfo = new ProcessStartInfo();
p.CreateNoWindow = true;
p.Verb = "print";
p.FileName = file;
p.Start();