我正在尝试从C#代码中打印Word文档。我使用了12.0.0.0 Word Interop,而我想做的是在打印文档之前弹出“打印对话”。我不确定这一切的语法,因为我无法使我的代码正常工作:(
有任何想法吗?
提前致谢!
最佳答案
应该是以下内容:
object nullobj = Missing.Value;
doc = wordApp.Documents.Open(ref file,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj);
doc.Activate();
doc.Visible = true;
int dialogResult = wordApp.Dialogs[Microsoft.Office.Interop.Word.WdWordDialog.wdDialogFilePrint].Show(ref nullobj);
if (dialogResult == 1)
{
doc.PrintOut(ref nullobj, ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj);
}