• Global Templates prompt to save at exit (VBA Word 2000)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Global Templates prompt to save at exit (VBA Word 2000)

    Author
    Topic
    #374668

    I’ve got code that uninstalls and deletes an existing global template (if it exists) and the installs another version of the same file.

    When I go to close Word, it asks if I want to save my changes to that global template, and quite often other unassociated global templates. Any idea why this happens and if I can/should get rid of this behavior?

    Thanks!!
    Troy

    Viewing 0 reply threads
    Author
    Replies
    • #606816

      You are treading the same water we all treaded before you floated along….

      Don’t you just hate that message?

      Anyway, your code IS changing the templates mentioned. Don’t argue. Word will not listen.

      To workaround this problem either:

      1) find the code that is changing the template and remove it, comment it out, change it, etc. Good Luck.
      2) for each template set the template.saved property to true in the, ah…. let’s see, the DocumentClose event of the template: ThisDocument.AttachedTemplate.Saved = True

      You can also use the FileExit sub (if you have one of your own).

      • #606877

        Actually, I thought I had seen this somewhere in my wanderings, but could not find it again.

        However, I can’t figure what is changing the template.

        I also tried using the close event, but that does not work either. If you can believe the online help, it says:

        “If the event procedure is stored in a template, the procedure will run when a new document based on that template is closed and when the template itself is closed (after being opened as a document).”

        Neither of these is the case, since I am only using the global template to add a custom menu and a host of macros. No document has this attached, nor is the template opened as a document. So, unless I’m misunderstanding, adding that is useless.

        Perhaps a better way to handle this is to save all open templates prior to ending my installation of the global template. Then the user is not confused by the prompt to save the template right after he/she has installed it.

        If you have a different solution, please let me know.

        Thanks!!
        Troy

        • #606934

          Troy,

          It definitely sounds like a better idea to save any relevant templates, at the end of the install, rather than wait until Word is closing.

          If you do have to have code run when Word is closing, I think an AutoExit sub in a (loaded) global template would be the place to put it.

          Gary

          • #606967

            Unfortunately, as I said in the previous post, that code does not run at all.

            And when tested using the close event, I found that the close event did not happen until after I was prompted to save.

            I think OK for now. I have code that will save during install so that user will not be prompted at that point. If they are prompted later, I don’t think that will be as bad.

            Thanks again!!
            Troy

        • #607142

          Gary mentioned the AutoExit sub. That doesn’t fire either??!! That *should* work no matter what. Sounds like something else is amiss.

    Viewing 0 reply threads
    Reply To: Global Templates prompt to save at exit (VBA Word 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: