COM ApplicationClass.Documents.Open 线程

发布于 2024-07-23 05:52:42 字数 558 浏览 0 评论 0原文

我正在使用 Interop word ApplicationClass.Documents.Open 方法打开 Word 文档。 在我的应用程序中,当我使用以下语句时,它会挂起: IE 显示它仍在加载,但它从不执行任何操作。

_Document aDoc = WordApp.Documents.Open(
    ref fileName, ref oMissing, ref readOnly, ref oMissing, ref oMissing,
    ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
    ref oMissing, ref isVisible, ref oMissing, ref oMissing, ref oMissing,
    ref oMissing);

我通过创建一个虚拟网站尝试了同样的事情,并且成功了。 问题是它只是无法在我的应用程序中打开Word文档。 这段代码有什么问题或者我还需要添加什么吗?

我还看到一个已创建并执行的线程,但不知道其起源于何处。

I am using the Interop word ApplicationClass.Documents.Open method to open a word document.
In my application when I use the below statement it hangs: IE shows it's still loading but it never does anything.

_Document aDoc = WordApp.Documents.Open(
    ref fileName, ref oMissing, ref readOnly, ref oMissing, ref oMissing,
    ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
    ref oMissing, ref isVisible, ref oMissing, ref oMissing, ref oMissing,
    ref oMissing);

I tried the same thing by creating a dummy website and it worked. The problem is it just does not open the word document in my application. Anything wrong in this code or is there something more I need to add to this?

I also see a thread which is created and executed but have no clue as to from where its originated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

摇划花蜜的午后 2024-07-30 05:52:42

从您的问题中我可以了解到,您正在尝试在 Web 服务器上使用 Word 应用程序本身(通过 COM 互操作)打开 Word 文档。

你不应该这样做。 Word 并不是为了在 Windows 服务上下文中运行而创建的。 也就是说,没有用户界面。

Word 可能正在对话框中等待用户的响应。 但由于您没有 UI,因此不会显示。

What I can understand from your question, you are trying to open a Word document, using the Word application itself (via COM interop) on a Web server.

You should not do this. Word is not created to run in the context of a Windows service. That is, without user interface.

Probably Word is waiting for some response from the user, in a dialog box. But since you do not have a UI, this will not show.

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