Hello,

The DocumentBeforeClose event gives me grief.

The problem is that I have to perform a certain cleanup operation when a =
document is closed.

Unfortunately, DocumentBeforeClose is called before the user is =
presented with the "Document changed, do you want to save?" dialog, =
which can cancel the close.

So, I do not know whether the document was actually closed.

Is there a way around it?

Thanks.


Best wishes,
Alex.

--=20
Address email to user "response" at domain "alexoren" with suffix "com"

Re: DocumentBeforeClose problems by Jean-Guy

Jean-Guy
Tue Aug 16 22:52:47 CDT 2005

Alex was telling us:
Alex nous racontait que :

> Hello,
>
> The DocumentBeforeClose event gives me grief.
>
> The problem is that I have to perform a certain cleanup operation
> when a document is closed.
>
> Unfortunately, DocumentBeforeClose is called before the user is
> presented with the "Document changed, do you want to save?" dialog,
> which can cancel the close.
>
> So, I do not know whether the document was actually closed.
>
> Is there a way around it?

In your BeforeClose event, check the value of
ActiveDocument.Saved
If it is false, then the document is "dirty" and Word will ask the user if
they want to save.
So, knowing that, create your own messagebox asking the user if they want to
save, if not, switch the value to True and carry on with your event, if they
do, save and then carry on with your event code.

I have not tested it (It is late here...), but I think it should work
because I remember doing something like a few years ago.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org



Re: DocumentBeforeClose problems by Michael

Michael
Wed Aug 17 01:12:29 CDT 2005

Am Tue, 16 Aug 2005 22:48:13 -0400 schrieb Alex:

Alex, I use DocumentChange. In this event I store the Documents.Count
and compare with previous values. If the count has decreased then I
search for my Document(s) to see if it´s (or one of them is) gone.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook

> Hello,
>
> The DocumentBeforeClose event gives me grief.
>
> The problem is that I have to perform a certain cleanup operation when
a document is closed.
>
> Unfortunately, DocumentBeforeClose is called before the user is
presented with the "Document changed, do you want to save?" dialog,
which can cancel the close.
>
> So, I do not know whether the document was actually closed.
>
> Is there a way around it?
>
> Thanks.
>
>
> Best wishes,
> Alex.

Re: DocumentBeforeClose problems by Alex

Alex
Thu Aug 18 13:04:59 CDT 2005

Hello Michael,

"Michael Bauer" <mb@mvps.org> wrote in message =
news:dtvharvsa0hg.r3wsofx5i50c$.dlg@40tude.net...
> Am Tue, 16 Aug 2005 22:48:13 -0400 schrieb Alex:
>=20
> Alex, I use DocumentChange. In this event I store the Documents.Count
> and compare with previous values. If the count has decreased then I
> search for my Document(s) to see if it=B4s (or one of them is) gone.

Excellent idea, I re-used it.

Except that there is no need to search since if the number of documents =
has changed, it means that the previously current document was closed.

I think this approach should also work for Window objects in conjunction =
with the WindowActivate event.


Best wishes,
Alex.

--=20
Address email to user "response" at domain "alexoren" with suffix "com"