Results 1 to 5 of 5
  1. #1
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    AutoExit Event Fires Twice

    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?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  2. #2
    calacuccia
    Guest

    Re: AutoExit Event Fires Twice

    Hi Kevin,

    If you have both templates loaded, the AutoExit event will be fired once for each template...

    But, an AutoExit firing twice, can only be because of code inside it, as far as I'm aware.

    I've tried adding this line in a AutoExit

    Application.Quit

    but this gave a DrWatson error.

    Apart from that error, I don't believe a double execution can do any harm.

    Could you post code for the AutoExec which fires twice?

    Calacuccia

  3. #3
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AutoExit Event Fires Twice

    Cala,

    Here's the Autoexit code in question:

    <pre>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
    </pre>


    Thanks for your help.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  4. #4
    calacuccia
    Guest

    Re: AutoExit Event Fires Twice

    Hey Kevin,

    I'm new to this forum (since yesterday), but I'm having trouble to copy code from the comments.

    e.g. the code you supplied in here, turns out on 1 single line when I paste it in the VBA Editor.

    Any idea why or how to get around this?

  5. #5
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AutoExit Event Fires Twice

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •