In my project I subscribe to the BeforeClose event. If I have two or more
documents open with this macro, all the documents gets hit by the event, not
just the one I am closing, no worries there. But what I would like to do is
to only have the document that's closing to run the code in the event. Is
there a way to prevent the other documents from running the code in the
events?

/Peter Tragardh

Re: Prevent BeforeClose event from running for every open document by JGM

JGM
Fri Dec 05 09:43:55 CST 2003

Hi Peter,

Yes, two ideas come to mind:

Customized document properties or Document variables.

Just check for the presence/value of a predefined property or varibale
before running the code.

I prefer the Document variable because it is totally invisible to the user,
so he/she cannot mess with it....

HTH
Cheers!

--
_______________________________________
Jean-Guy Marcil
jmarcil@sympatico.ca

"Peter Trägårdh" <peter_tragardh@hotmail.com> a écrit dans le message de
news: eW3pdJ0uDHA.3744@TK2MSFTNGP11.phx.gbl...
> In my project I subscribe to the BeforeClose event. If I have two or more
> documents open with this macro, all the documents gets hit by the event,
not
> just the one I am closing, no worries there. But what I would like to do
is
> to only have the document that's closing to run the code in the event. Is
> there a way to prevent the other documents from running the code in the
> events?
>
> /Peter Tragardh
>
>



Re: Prevent BeforeClose event from running for every open document by Peter

Peter
Tue Dec 16 09:20:33 CST 2003

Any ideas on how to create a unique value for every document? I can't
hard code it since the macro is in the dot-file. Every doc-file would get
the same value.

And if I create a unique value dynamically for every document, how does
the save event know which value to check for?


"JGM" <no-spam@leaveme.alone> wrote in
news:#Z$atW0uDHA.3140@TK2MSFTNGP11.phx.gbl:
> Hi Peter,
>
> Yes, two ideas come to mind:
>
> Customized document properties or Document variables.
>
> Just check for the presence/value of a predefined property or varibale
> before running the code.
>
> I prefer the Document variable because it is totally invisible to the
> user, so he/she cannot mess with it....
[SNIP]
> "Peter Trägårdh" <peter_tragardh@hotmail.com> a écrit dans le message
> de news: eW3pdJ0uDHA.3744@TK2MSFTNGP11.phx.gbl...
>> In my project I subscribe to the BeforeClose event. If I have two or
>> more documents open with this macro, all the documents gets hit by
>> the event, not
>> just the one I am closing, no worries there. But what I would like to
>> do is
>> to only have the document that's closing to run the code in the
>> event. Is there a way to prevent the other documents from running the
>> code in the events?

Re: Prevent BeforeClose event from running for every open document by JGM

JGM
Tue Dec 16 09:41:50 CST 2003

Hi Peter,

Create the value in the Document_New Event.

If you want the BeforeClose to run, create the Document Variable with the
value "YES" for those that need the procedure to run, and the Value "NO" for
the others.
Then you can hard code:
(In Pseudo code)

If Document_Variable("Check_First") = "YES" then run code in
BeforeClose....

HTH
Cheers!

--
_______________________________________
Jean-Guy Marcil
jmarcil@sympatico.ca

"Peter Tragardh" <peter.tragardh@hotmail.com> a écrit dans le message de
news: Xns9453A6417ACBpetertragardhhotmail@207.46.248.16...
> Any ideas on how to create a unique value for every document? I can't
> hard code it since the macro is in the dot-file. Every doc-file would get
> the same value.
>
> And if I create a unique value dynamically for every document, how does
> the save event know which value to check for?
>
>
> "JGM" <no-spam@leaveme.alone> wrote in
> news:#Z$atW0uDHA.3140@TK2MSFTNGP11.phx.gbl:
> > Hi Peter,
> >
> > Yes, two ideas come to mind:
> >
> > Customized document properties or Document variables.
> >
> > Just check for the presence/value of a predefined property or varibale
> > before running the code.
> >
> > I prefer the Document variable because it is totally invisible to the
> > user, so he/she cannot mess with it....
> [SNIP]
> > "Peter Trägårdh" <peter_tragardh@hotmail.com> a écrit dans le message
> > de news: eW3pdJ0uDHA.3744@TK2MSFTNGP11.phx.gbl...
> >> In my project I subscribe to the BeforeClose event. If I have two or
> >> more documents open with this macro, all the documents gets hit by
> >> the event, not
> >> just the one I am closing, no worries there. But what I would like to
> >> do is
> >> to only have the document that's closing to run the code in the
> >> event. Is there a way to prevent the other documents from running the
> >> code in the events?