如何查找新创建的文档或现有文件 [英] How to find document is newly created or existing file
问题描述
您好,
我正在使用vsto add in(Visual Studio 2017)为Word创建新的插件。
I am creating new add in for Word using vsto add in (visual studio 2017).
其中,我需要的功能很少,如果我的服务器上已经创建了文档,那么它应该被覆盖。如果没有,则应打开自定义弹出窗口并询问位置。 (完整功能是根据单词的保存事件,除了位置)
In which, i need few functionality, that if document is already created on my server then it should be over-written. and if not then custom pop should open and ask for location. (full functionality is as per word's save event,except location)
所以我需要:
1。需要查看是否使用新模板或其打开的现有文档创建了已打开的文档。
1. Need to find whether opened document is created using new template or its opened existing document.
我如何才能获得该文档?
How can i get that ?
推荐答案
嗨 DhrumilKothari,
Hi DhrumilKothari,
为了查找新创建的文档或现有文件,请尝试下面的代码:
In order to find document is newly created or existing file, please try the code below:
if (string.IsNullOrEmpty(WordInstance.ActiveDocument.Path))
{
throw new ApplicationException("Document must be saved first");
}
如需了解更多信息,请查看以下链接:
For more information, please review the following link:
vsto - 如果从空白文档创建或从现有文档打开,则确定word文档
希望它对您有所帮助。期待收到您的回复。
Hopefully it helps you. Looking forward to hearing from you.
最诚挚的问候,
这篇关于如何查找新创建的文档或现有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!