A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

macro lifecycle?



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 2nd 06, 07:11 PM posted to microsoft.public.outlook.program_vba
Jiho Han
external usenet poster
 
Posts: 5
Default 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


  #2  
Old June 2nd 06, 07:55 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default 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



  #3  
Old June 2nd 06, 10:04 PM posted to microsoft.public.outlook.program_vba
Jiho Han
external usenet poster
 
Posts: 5
Default 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



  #4  
Old June 2nd 06, 10:34 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default 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


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tacking Macro Bob_BLC Outlook and VBA 8 December 5th 07 07:00 AM
Reply macro... [email protected] Outlook and VBA 4 June 2nd 06 11:53 AM
Rules an macro Gerd Neumann Outlook and VBA 4 May 17th 06 10:48 PM
$$ looking for someone to write a macro for me [email protected] Outlook and VBA 0 March 16th 06 12:24 AM
outlook macro matt Outlook and VBA 1 January 30th 06 02:30 PM


All times are GMT +1. The time now is 09:05 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-2025 Outlook Banter.
The comments are property of their posters.