【问题标题】:Save VSTO Word 2007 Template application to docx without prompt to save template将 VSTO Word 2007 模板应用程序保存到 docx 而不提示保存模板
【发布时间】:2010-10-11 10:52:09
【问题描述】:

重现步骤:

  1. 创建 Word 2007 模板项目 (Visual Studio 2008 Professional SP1)
  2. 在文档上放置 DateContentControl
  3. 保存、发布、打开 .dotx
  4. 修改 DateContentControl,保存
  5. 点击否,关闭单词
  6. 打开保存的文档,修改 DateContentControl - 以后保存时不再提示...
  7. 更改项目代码,发布,更新 V​​STO 应用,打开 .dotx,重复步骤 4

Word 2007 模板应用程序如何允许用户在不提示保存的情况下修改文档?

【问题讨论】:

    标签: c# ms-word vsto


    【解决方案1】:

    谢谢迪沃。

    下面是 C# 中用于 VSTO 的两行代码:

    Word.Template template = (Word.Template)this.Application.ActiveDocument.get_AttachedTemplate();
    template.Saved = true;
    

    【讨论】:

      【解决方案2】:

      Word 检查文档的附件模板是否被修改,并提示是否保存更改。为避免出现此类提示,您可以将附加模板的 Saved 属性设置为 true。

      在 VBA 中,这将是:

      ActiveDocument.AttachedTemplate.Saved = True
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-02-03
        • 2010-11-17
        • 1970-01-01
        相关资源
        最近更新 更多