打印使用Word互操作与打印对话框 [英] Printing using Word Interop with Print Dialog

查看:254
本文介绍了打印使用Word互操作与打印对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的C#代码打印Word文档。我用的是12.0.0.0的Word互操作性和我想要做的是得到一个打印对话打印文档前弹出。我不是100%肯定这一切的语法,因为我不能让我的代码工作:(
任何想法吗?

I'm trying to print a word doc from my C# code. I used the 12.0.0.0 Word Interop and what i'm trying to do is to get a Print Dialogue pop up before the document prints. I'm not 100% sure of the syntax of all of this as I can't get my code to work :( Any ideas?

谢谢!前进

推荐答案

这应该是沿着线的东西:

It should be something along the lines of:

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);
}

这篇关于打印使用Word互操作与打印对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆