使用 Process.Start 打印文档而不显示 Word

发布于 2024-07-17 06:43:02 字数 557 浏览 4 评论 0原文

我正在使用以下代码从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小嗲 2024-07-24 06:43:02

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文