简体   繁体   English

如何使用vb.net在后台打开Word文件?

[英]How to open word file in background using vb.net?

I am working on creating multiple documents from source document. 我正在根据源文档创建多个文档。

I am using: 我在用:

objWordApp.Documents.Open("D:\Template\Aptletter.doc")

I modify the above document and save in another folder. 我修改了上面的文档并保存在另一个文件夹中。

While creating documents, word files are opening and closing multiple times. 创建文档时,Word文件会多次打开和关闭。 So user unable to do another work on the same PC. 因此用户无法在同一台PC上进行其他工作。

How to stop open file or Is there any method to modify document without above method? 如何停止打开文件或没有上述方法可以修改文件吗?

So please suggest 所以请建议

Thanks in Advance 提前致谢

DEV DEV

The visibility of a word document being controlled via interop can be set using the WordApplication.Visible attribute. 可以使用WordApplication.Visible属性设置通过互操作控制的Word文档的可见性。

This attribute is, as you can see, at the Application level. 如您所见,此属性在应用程序级别。 If you've already opened a document using that WordApplication , you can't suddenly make the application invisible using the attribute. 如果您已经使用该WordApplication打开了文档,则无法使用属性突然使该应用程序不可见。

What you can do, though, is create another instance of WordApplication . 但是,您可以做的是创建WordApplication另一个实例。 Call it InvisibleWordApplication for clarity, and set InvisibleWordApplication.Visible = false right from the start. 为了清楚起见,将其称为InvisibleWordApplication.Visible = false ,并从一开始就设置InvisibleWordApplication.Visible = false Then open your document using that application, and you should be set. 然后使用该应用程序打开文档,然后进行设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM