将 VSTO Word 2007 模板应用程序保存到 docx,而不提示保存模板

发布于 2024-07-14 04:03:27 字数 351 浏览 6 评论 0原文

重现步骤:

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

Word 2007 模板应用程序如何允许用户修改文档而不提示保存?

Steps to reproduce:

  1. Create Word 2007 Template Project (Visual Studio 2008 Professional SP1)
  2. Place DateContentControl on document
  3. Save, Publish, open .dotx
  4. Modify DateContentControl, Save
  5. Click No, Close Word
  6. Open Saved document, Modify DateContentControl - no more prompts on subsequent saves...
  7. Change project code, publish, update VSTO app, open .dotx, repeat step 4

How does a Word 2007 Template application allow a user to modify the document without getting prompted on a save?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

牵强ㄟ 2024-07-21 04:03:27

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

在 VBA 中,这将是:

ActiveDocument.AttachedTemplate.Saved = True

Word checks whether the attached template of a document has been modified and prompts whether to save the changes. To avoid such a prompt you could set the Saved property of the attached templated to true.

In VBA this would be:

ActiveDocument.AttachedTemplate.Saved = True
相思故 2024-07-21 04:03:27

谢谢迪沃。

以下是 VSTO 的 C# 中的 2 行:

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

Thanks divo.

Here are the 2 lines in C# for VSTO:

Word.Template template = (Word.Template)this.Application.ActiveDocument.get_AttachedTemplate();
template.Saved = true;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文