Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   macro lifecycle? (http://www.outlookbanter.com/outlook-vba/16670-macro-lifecycle.html)

Jiho Han June 2nd 06 07:11 PM

macro lifecycle?
 
I have a global variable in my macro project, which gets set by a macro function
if it is Nothing. Depending on this variable, a login form is shown for
the user to login, etc.

When does the global variable get cleaned up? When I run the macro subsequently,
sometimes the variable is still intact, and sometimes, it's not, so it gets
recreated.

Should the macro not depend on any existing state when it runs, so that each
run of the macro is an atomic transaction? If so, what is a good place to
store a session (current outlook session, until the outlok closes) level
information?

Thanks

Jiho Han
Senior Software Engineer
Infinity Info Systems
The Sales Technology Experts
Tel: 212.563.4400 x216
Fax: 212.760.0540

www.infinityinfo.com



Ken Slovak - [MVP - Outlook] June 2nd 06 07:55 PM

macro lifecycle?
 
A true global will go out of scope just before Application_Quit fires. If
it's initialized during the life of an Outlook session it should retain
values as long as that session is running.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Jiho Han" wrote in message
.com...
I have a global variable in my macro project, which gets set by a macro
function if it is Nothing. Depending on this variable, a login form is
shown for the user to login, etc.

When does the global variable get cleaned up? When I run the macro
subsequently, sometimes the variable is still intact, and sometimes, it's
not, so it gets recreated.

Should the macro not depend on any existing state when it runs, so that
each run of the macro is an atomic transaction? If so, what is a good
place to store a session (current outlook session, until the outlok
closes) level information?

Thanks

Jiho Han
Senior Software Engineer
Infinity Info Systems
The Sales Technology Experts
Tel: 212.563.4400 x216
Fax: 212.760.0540

www.infinityinfo.com




Jiho Han June 2nd 06 10:04 PM

macro lifecycle?
 
Would it matter where the variable is defined?

i.e.) ThisOutlookSession vs. your own module (not class)

The declaration would be something like this:

Global CurrentSession As ADODB.Connection

A true global will go out of scope just before Application_Quit fires.
If it's initialized during the life of an Outlook session it should
retain values as long as that session is running.

"Jiho Han" wrote in message
.com...

I have a global variable in my macro project, which gets set by a
macro function if it is Nothing. Depending on this variable, a login
form is shown for the user to login, etc.

When does the global variable get cleaned up? When I run the macro
subsequently, sometimes the variable is still intact, and sometimes,
it's not, so it gets recreated.

Should the macro not depend on any existing state when it runs, so
that each run of the macro is an atomic transaction? If so, what is
a good place to store a session (current outlook session, until the
outlok closes) level information?

Thanks

Jiho Han
Senior Software Engineer
Infinity Info Systems
The Sales Technology Experts
Tel: 212.563.4400 x216
Fax: 212.760.0540

www.infinityinfo.com




Ken Slovak - [MVP - Outlook] June 2nd 06 10:34 PM

macro lifecycle?
 
A public in a code module should be truly global. Just try declaring any 2
variables with the same name as public.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Jiho Han" wrote in message
.com...
Would it matter where the variable is defined?

i.e.) ThisOutlookSession vs. your own module (not class)

The declaration would be something like this:

Global CurrentSession As ADODB.Connection




All times are GMT +1. The time now is 07:04 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com