使用C#打开MS Word [英] Open MS Word Using C#

查看:103
本文介绍了使用C#打开MS Word的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想控制用户打开和关闭一些MS Word文档.
在我的程序中,当用户要打开文档时,我创建了一个新的Word.Application和一个新的Document,然后打开了该文档.
当用户关闭文档或MS Word时,我想提示用户是否要覆盖exsit文件.我希望有人想给我一个解决方案.

I want to control the user open and close some MS Word document.
In my program,when the user want to open a document,I create a new Word.Application and a new Document ,then open the document.
when the user close the document or the MS Word,I want to prompt the user if he or she would like to overwrite the exsit file.I hope someone would like to give me a solution.

推荐答案

如果使用SaveFileDialog询问用户要将文件保存到的位置,则可以将OverwritePrompt属性设置为true,然后将提示用户是否要覆盖现有文件文件.
If you use a SaveFileDialog to ask the user where they would like to save the file to, then you can set the OverwritePrompt property to true, and then the user will be prompted if they want to overwrite an existing file.


好吧,您可以查看Microsoft Office工具,以了解通过.NET控制Word的方法,但是我不确定它们是否允许您这样做. Word本身会提示您保存文件,然后在.doc文件上运行Process.Start将在Word中打开它.
Well, you could look at the Microsoft Tools for Office, for ways to control Word via .NET, but I''m not sure they will allow you to do that. Word itself should prompt you to save a file, and Process.Start on a .doc file will open it in Word.


这篇关于使用C#打开MS Word的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆