使用microsoft.office.interop.word以写模式打开Ms Word

本文关键字:模式 Ms Word microsoft office interop word 使用 | 更新日期: 2023-09-27 17:50:43

我试图通过c#打开MS Word文档。但是open方法是以只读模式打开文档的。我希望以写模式打开文件,而不创建另一个I副本,这样我就可以将更改保存到Database。下面是打开文件的代码:

public void def()
{
    Word.Application app = new Word.Application();
    Word.Document dd = app.Documents.Open("C:''hi12.docx", ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing,ref repair);
    dd.TrackRevisions = true;
    dd.CommandBars["Reviewing"].Controls["Reviewing Pane"].Execute();
    int count = dd.Words.Count;
    dd.Close(ref Nothing, ref format, ref Nothing);
}

使用microsoft.office.interop.word以写模式打开Ms Word

这有帮助吗?
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.view.readinglayoutallowediting

此外,当不在客户端上运行时,不应该使用互操作(asp.net在服务器上运行)。
你当然也需要关闭你的应用。