Data Persistence Across Scripts?

  • Thread starter Thread starter Mike H.
  • Start date Start date
M

Mike H.

I've created a script that is called from the Rules Wizard
as "Run My Script" on all incoming messages.

It's my own home-grown rule-processor, called MyRules. It
had originally initialized its rules during run-time,
every time it was invoked. I recently split it in two, so
that the rules would be read in from a file once when
Outlook starts up.

The "Application_Startup" subprogram (in This
OutlookSession) correctly initializes the list of rules.
But when MyRules runs, the rule list is empty. I cannot
figure out why the list is correctly initialized on
startup, but is then empty when MyRules runs.

The Rule List is declared in "Modules|Module1" as a
public, dynamic array. The element type for the Rule List
(A_Rule) is also declared as a public type:

Public Type A_Rule
:
End Type

Public RuleList() As A_Rule

Any help/insight anyone can provide will be appreciated.

Thanks,
Mike
 
The list of scripts that can be run in the Rules Wizard is dependent on
how your procedure is constructed. These Subs must accept one argument
of type MailItem or MeetingItem (e.g. Sub MyProcedure(Item as Outlook.MailItem))
or it will not be listed in the Rules Wizard.
Eric Legault - B.A, MCP, MCSD, Outlook MVP
 
Eric:

Thanks for the reply!

The script that's run from the Rules Wizard correctly has
the single argument of type MailItem:
Sub MyRules(Item As Outlook.MailItem)

The problem is that my list of rules that I create at
startup is empty when MyRules is invoked. The rules look
fine when Application_Startup ends, but they're empty when
MyRules starts. The list of rules is declared as Public,
so I can't figure out what the problem is.

Thanks again,
Mike
 
I pasted the code below into the ThisOutlookSession module, went through the
Rules Wizard, chose "Run a script" as one of the actions, and clicked on the
"script" hyperlink. The procedure below was correctly listed. What version
of Outlook are you using?

Sub MyRules(Item As Outlook.MailItem)

End Sub

After rereading your post, it sounds like you are trying to have a procedure
fill that list of scripts. That list is automatically generated by looking
for any procedures that follow the standard of "Item As Outlook.<itemtype>"
for the single argument. So you should have one procedure for each of your
rules, and choose which one to execute based on the conditions you specify
for a single rule using the Rules Wizard.

Am I on the right track of understanding your problem?
 
Eric:

Thanks for the help!

I'm running Outlook 2002, SP-2.

I just hopped into my scripts to grab some debug info for
you, but, well, the stoopid thing is running fine now!

So again, thanks for the help. If the thing acts up again
I'll let you know. ;^)

Mike
 
Back
Top