我使用以下方法在 FormLoad 上动态打开/创建了一个新的 Word 文档:
- 使用 Word = Microsoft.Office.Interop.Word;
- oWord = new Word.Application();
- oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);
我有“保存按钮”,它使用以下方法保存所述文档:
- oDoc.SaveAs(ref filename, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref o缺失);
然后我在 FormClosed 上添加了关闭文档的语法:
- oDoc.Close(ref oMissing, ref oMissing, ref oMissing);
场景:我运行我的程序并在之后关闭/退出。突然弹出文档的“另存为”对话框。我意识到我没有保存文档,因为保存过程在“保存按钮”中。
如何保存文档或自动选择“取消”进行保存?有帮助的人吗?