Question

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?

Was it helpful?

Solution

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

OTHER TIPS

Thanks divo.

Here are the 2 lines in C# for VSTO:

Word.Template template = (Word.Template)this.Application.ActiveDocument.get_AttachedTemplate();
template.Saved = true;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top