使用 Process.Start 打印文档而不显示 Word
我正在使用以下代码从 C# 应用程序打印 Word 文档。
ProcessStartInfo info = new ProcessStartInfo(myDocumentsPath);
info.Verb = "Print";
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(info);
这工作正常,Word 打开并打印文档,然后自行关闭。 问题是,尽管 CreateNoWindow = true 且 WindowsStyle =Hidden,Word 仍然可以明显打开。 我本以为这两个设置意味着 Word 以静默方式打开。
编辑:请不要建议 Word 对象模型自动化 - 我有许多不同的文档类型需要打印(PDF 等) - 目前只是 Word 文档导致了问题。
有什么想法吗?
蒂亚马特
I am using the following code to print a word document from a C# app.
ProcessStartInfo info = new ProcessStartInfo(myDocumentsPath);
info.Verb = "Print";
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(info);
This works fine Word opens and prints the document, and then closes itself down. The issue is that Word opens visibly, despite CreateNoWindow = true, and WindowsStyle =Hidden. I would have expected these two settings to mean that Word opened silently.
EDIT: Please don't suggest Word object model automation - I have many different document types that need to be printed (PDF etc) - it is just Word docs that are causing the issue at the moment.
Any thoughts?
TIA
Matt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Word 可以随意忽略(并且显然确实忽略)您将其保持隐藏的请求。
另请参阅为什么我的隐藏进程仍然可见?
Word is free to ignore (and apparently does ignore) your request that it remain hidden.
See also Why is my hidden process still visible?