Application.Quit: events not fired ?? 
Author Message
 Application.Quit: events not fired ??

Hi All,

Due to a usergroup request I added an "Exit" button on a Word
application Toolbar.

This Exit button has to do exactly the same as File --> Exit or the
upper-right X, but due to ergonomic reasons the users want the Exit at
their application toolbar.

The code I used behind the button is:

Public Sub ExitHellas()

    Call Application.Quit

End Sub

Now I see the following strange behaviour:

When the user uses the File-->Exit or the uppr-right X, the
DocumentBeforeClose etc.. and the Quit event are fired.

But when using my Exit-button (see code) these events are not fired,
even no events seem to be fired at all, but I'm not sure of this last
assertion!

Environment info:
I use a class where these events are used and I use the DOT-file as an
Add-In
and:
W2K Prof and OfficeXP 9Word 2002).

What do I do wrong??

Best regards,

Hans Troost



Mon, 01 Aug 2005 20:55:51 GMT  
 Application.Quit: events not fired ??
Hi Hans,

Try the following:

Public Sub ExitHellas()
    ThisDocument.Close
End Sub

Private Sub App_DocumentBeforeClose(ByVal Doc As Document, _
    Cancel As Boolean)
    'Terminates Word, but only if closing the add-in
    If Doc.AttachedTemplate = ThisDocument Or _
        Doc = ThisDocument Then
        Application.Quit
    End If
End Sub

Krgrds,
Perry



Quote:
> Hi All,

> Due to a usergroup request I added an "Exit" button on a Word
> application Toolbar.

> This Exit button has to do exactly the same as File --> Exit or the
> upper-right X, but due to ergonomic reasons the users want the Exit at
> their application toolbar.

> The code I used behind the button is:

> Public Sub ExitHellas()

>     Call Application.Quit

> End Sub

> Now I see the following strange behaviour:

> When the user uses the File-->Exit or the uppr-right X, the
> DocumentBeforeClose etc.. and the Quit event are fired.

> But when using my Exit-button (see code) these events are not fired,
> even no events seem to be fired at all, but I'm not sure of this last
> assertion!

> Environment info:
> I use a class where these events are used and I use the DOT-file as an
> Add-In
> and:
> W2K Prof and OfficeXP 9Word 2002).

> What do I do wrong??

> Best regards,

> Hans Troost



Thu, 04 Aug 2005 19:29:28 GMT  
 Application.Quit: events not fired ??
Hi Perry,

Thanks for your answer, but I'm afraid it doesn't work for the
following reasons:

1. the AttachedTemplate is not the Add-In: the add-in is loaded by
starting Word with /L<add-in.dot> and when it runs, different
templates are used when creating documents. Which one is determined by
user-input. So the AttachedTemplate is always ione of these templates
and never the Add-in
2. The Exit has to function exactly in the same way, the normal exit
works: so has to be aware of:
A. Multiple documents open and
B. Not all documents have to be HELLAS-documents
(my-application-documents) but also can be just "normal documents.

So what I need is just exactly what the normal file-exit does, but
added to my toolbar.

So, right now (when typing this) the following comes up: I will try
just the simple "Sendkeys" to quit Word. I hope this works

If some of you readers are interested in the results, please let me
know (can be mailed directly to me) and I'll keep you informed.

Regards,

Hans

PS: I still am amazed that the Application.Quit not automatically does
the same as File--> Exit. HT.

Quote:

> Try the following:

> Public Sub ExitHellas()
>     ThisDocument.Close
> End Sub

> Private Sub App_DocumentBeforeClose(ByVal Doc As Document, _
>     Cancel As Boolean)
>     'Terminates Word, but only if closing the add-in
>     If Doc.AttachedTemplate = ThisDocument Or _
>         Doc = ThisDocument Then
>         Application.Quit
>     End If
> End Sub

> Krgrds,
> Perry



Fri, 05 Aug 2005 22:28:28 GMT  
 Application.Quit: events not fired ??

Quote:
> The code I used behind the button is:

> Public Sub ExitHellas()

>     Call Application.Quit

> End Sub

When you write Call Application.Quit, what is the expected behaviour?
Do you mean to use the method "Application.Quit", in which case, Word closes
and all the code in the beforeClose event may not be executed. I have had
problems with this before.

But if you are calling a procedure you wrote, I hope you did not call it
"Quit" because that causes conflicts in the code. Why the Call before
Application.Quit?



Quote:
> Hi All,

> Due to a usergroup request I added an "Exit" button on a Word
> application Toolbar.

> This Exit button has to do exactly the same as File --> Exit or the
> upper-right X, but due to ergonomic reasons the users want the Exit at
> their application toolbar.

> The code I used behind the button is:

> Public Sub ExitHellas()

>     Call Application.Quit

> End Sub

> Now I see the following strange behaviour:

> When the user uses the File-->Exit or the uppr-right X, the
> DocumentBeforeClose etc.. and the Quit event are fired.

> But when using my Exit-button (see code) these events are not fired,
> even no events seem to be fired at all, but I'm not sure of this last
> assertion!

> Environment info:
> I use a class where these events are used and I use the DOT-file as an
> Add-In
> and:
> W2K Prof and OfficeXP 9Word 2002).

> What do I do wrong??

> Best regards,

> Hans Troost



Mon, 15 Aug 2005 06:19:21 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. click event not firing if lost_focus is firing first

2. ReadProperties event and WriteProperties event are not firing

3. Quit application event

4. VBA5 Application Event QUIT

5. Access 97 - Application.Quit does not work if msgbox is displayed

6. Control Event Problem (Post Event after an event is fired)

7. Terminate Event not Fired

8. BeforeDelConfirm, AfterDelConfirm events not firing

9. Inspector_Close Event Not Firing

10. Outlook 2000 Add-in : Disconnect events do not fire

11. Event does not fire after showing a form

12. Form events not firing in public folder

 

 
Powered by phpBB® Forum Software