Visual Studio - 使用Word API调试应用程序是不可能的

发布于 2024-07-15 19:02:04 字数 126 浏览 3 评论 0原文

我有一个使用 MS-Word API 的应用程序。 当尝试使用打开文档的函数 Document.Open(Filename) 时,我陷入困境。 我是否在调试或发布模式下运行并不重要。 任何帮助,将不胜感激。 谢谢你, 盖·马罗姆

I have an application which uses the MS-Word API.
I get stuck when trying to use the function Document.Open(Filename) which is the function that is opening a document.
It doesn't matter if I run in debug or release mode.
Any help would be appreciated.
Thank you,
Guy Marom

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

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

发布评论

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

评论(1

旧话新听 2024-07-22 19:02:04

Open 方法还需要更多参数!

object fileName = "MyDocuemnt.docx";
object readOnly = false;
object isVisible = true;
object missing = System.Reflection.Missing.Value;
WordApp.Visible = true;
Word.Document aDoc = WordApp.Documents.Open(ref fileName, ref missing,ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible);
aDoc.Activate();

.Net 中的 Word(和 Office)API 需要所有参数,而不是 VBA,因此长长的缺失线

很痛苦,但是如果解决方案变得很大,您可以创建一些包装类来将其隐藏在主应用程序逻辑中和复杂的

There are a bunch more paramters you need for the Open method!

object fileName = "MyDocuemnt.docx";
object readOnly = false;
object isVisible = true;
object missing = System.Reflection.Missing.Value;
WordApp.Visible = true;
Word.Document aDoc = WordApp.Documents.Open(ref fileName, ref missing,ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible);
aDoc.Activate();

The Word (and Office) API from .Net requires all paramters as opposed to VBA, hence the long line of missing's

It's a pain, but you can make some wrapper classes to hide this from your main application logic if the solution is to become large and complex

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