persistent variables (?)

  • Thread starter Thread starter JIMBOLUKE
  • Start date Start date
J

JIMBOLUKE

In Outlook (2003 or 2007), I have a dumb, general question relating to the
persistence of variables. If I want to load an array variable with values
from a text file, and I want to use these values in a macro procedure when I
fire a macro to process a message in my inbox, do I have to reload the array
from the text file each time I fire the macro? Rather, I'd like to not have
to do that. Is there a type of variable or a way to set up the variable so
that it only is loaded once each time I open Outlook? I hope this makes
sense.
 
Declare a variable in your ThisOutlookSession code window, for example:-

Public MyArray(5) as String

Now create a routine that will load the variables when Outlook starts, again
in the ThisOutlookSession code window, for example:-

Public Sub Application_Startup()
MyArray(1)="This"
MyArray(2)="Is"
MyArray(3)="The"
MyArray(4)="Answer"
End Sub
 
great. simple answer!!

Alan Moseley said:
Declare a variable in your ThisOutlookSession code window, for example:-

Public MyArray(5) as String

Now create a routine that will load the variables when Outlook starts, again
in the ThisOutlookSession code window, for example:-

Public Sub Application_Startup()
MyArray(1)="This"
MyArray(2)="Is"
MyArray(3)="The"
MyArray(4)="Answer"
End Sub

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.
 
If the variables are string variables (or can be reconciled to string
variables using CStr) and they are the same each time you run the macro you
could consider writing them to a text file. The macro could read the text
file each time the macro is run. I do this a lot and it works really well.

GP
 
Back
Top