• AutoExit Event Fires Twice

    Author
    Topic
    #351980

    I have two global templates and each has an AutoExit sub. When I exit Word, will each one run? What I noticed is that one of the AutoExit subs executes twice. This seems odd, but who has some knowledge of the way this is supposed to work? And can anyone confirm: the same autoexit executing twice doesn’t do any harm, right?

    Viewing 1 reply thread
    Author
    Replies
    • #511287

      Cala,

      Here’s the Autoexit code in question:

      Sub AutoExit()
      Dim aDoc As Document
      Dim aTemplate As Template
      
          On Error Resume Next
          Kill "c:PERB.log"
          
          For Each aDoc In Documents
              aDoc.AttachedTemplate.Saved = True
          Next
          
          ThisDocument.AttachedTemplate.Saved = True
          
          For Each aTemplate In Templates
              If aTemplate.Name Like "PERB*" Then
                  aTemplate.Saved = True
              End If
          Next
      End Sub
      

      Thanks for your help.

    • #511325

      Code executing more than once can do harm or it may not do harm.

      Depends on the code.

      If there is a possibility of more than one AutoExit running, then each has to fend for itself and take care to keep track of things AS IF it were the only AutoExit running.

    Viewing 1 reply thread
    Reply To: AutoExit Event Fires Twice

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

    Your information: