Is there a way to never save templates in Word? We have a lot of templates that we use to create standard documents. When a document based on one of these templates is closed, the user is asked if they want to save changes to the template. I wrote a macro that prevents this, but only if the main document was saved just prior to closing. Is there a way to prevent the template from ever being saved/changed from a document that is based in it?

migrated from stackoverflow.com Feb 5 '13 at 15:46

This question came from our site for professional and enthusiast programmers.

  • 1
    this isn't about programming but usage of microsoft products. – Gung Foo Feb 5 '13 at 12:55
  • Perhaps I should have been more specific. Is there a way to make way to trigger a macro based on the save event that happens when a user closes a document and is prompted to save? My on save event macro on seems to fire when the user clicks save. Also, is there a trick to using the on close event to trigger a macro? – MechEng Feb 5 '13 at 13:19
  • This discussion may be helpful: support.microsoft.com/kb/918064 – burrowsrjl Feb 5 '13 at 19:04

I reviewed the link above and it lead me to the answer. I am creating the new documents with a macro that loads the proper template. i just added two lines to the macro:


The first line makes the template appear to be saved (so that user is not prompted). The second line breaks the connectioun to the template. (this sets the associated template to "Normal".

This appears to be a good solution to ensure that the user never accidentally saves any formatting changes back to the master template.


There is no setting to suppress the prompt, but VBA can do it.

In the macro editor, select the Normal project and click Insert > Class Module. In the Properties pane, change the name of the class module to EventClassModule. (If you don't see the Properties pane, press F4 or click View > Properties Window.)

In the code window for the class module, paste this code:

Public WithEvents App As Word.Application

Private Sub App_DocumentBeforeSave(ByVal Doc As Document, _
        SaveAsUI As Boolean, Cancel As Boolean)
    If Doc Is ActiveDocument And ActiveDocument.AttachedTemplate <> ActiveDocument Then
        Doc.AttachedTemplate.Saved = True ' avoid saving template
    End If
End Sub

Also in the Normal project, add a regular module (Insert > Module) and add this code to it:

Dim X As New EventClassModule

Sub AutoExec()
    Set X.App = Word.Application
End Sub

Sub AutoExit()
    Set X = Nothing
End Sub

Author: Jay Freedman Source: http://answers.microsoft.com/en-us/office/forum/office_365hp-word/i-never-want-to-save-changes-to-template-from-a/f1cc78f8-2f2f-4c45-a3fb-731a9105a5a8

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.