persistent variables (?)

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.
 
A

Alan Moseley

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
 
J

JIMBOLUKE

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.
 
G

GP

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top