macros vs. VBA in outlook 2003

T

tom

I have OL2003 with a project called VbaProject.OTM

It contains a couple Windows API definitions, one or two Private Functions
and a Sub CustomMailMessageRule

For all incoming email, this code is run via a Rule called
Test.ThisOutlookSession.CustomMailMessageRule

How could I change that and what do I need to do to run just VBA code
against all incoming email and *not* run this via a Rule ?

The Rule is set to active (checkbox) via Rules and Alerts.

The reason I ask this is that sometimes, at random, the Rule has some error
(despite On Error Goto) and the
Test.ThisOutlookSession.CustomMailMessageRule is unchecked in Rules and
Alerts and none of the actions in the Sub CustomMailMessageRule are executed

Hope my question is clear.
 
M

Michael Bauer [MVP - Outlook]

You could use the ItemAdd event, which is fired when an item is added to the
folder. But then you'd have to code all the rule condition as well.

Before doing that I'd try to figure out why errors occur. What's your code,
and which lines raises the error?

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Thu, 22 Jan 2009 23:28:02 +0200 schrieb tom:
 
T

tom

Before doing that I'd try to figure out why errors occur. What's your
code,
and which lines raises the error?

unknown as only a messagebox from OL2003 comes up but does not tell me any
debug on what's wrong.

it's also totally random, hundreds of messages are processed daily and does
not happen every day

I also don't know why it removes the checkbox from the Rules and Alerts
(right in front of the rule name in the list)
 
M

Michael Bauer [MVP - Outlook]

I think it disables the rule due to the error. Without the code we can't fix
it.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Fri, 23 Jan 2009 01:40:45 +0200 schrieb tom:
 
T

tom

Michael said:
I think it disables the rule due to the error. Without the code we can't fix
it.

the code is several hundred lines inside that one Sub CustomMailMessageRule

the question is really if there is a way when some error happens to have it tell me
why OL2003 thinks there is an error?

the error messagebox does not tell anything why or where there is some problem and as
I mentioned, days or weeks may pass without an error so I can't even force it.
 
M

Michael Bauer [MVP - Outlook]

You just need an error handler. That might look like this:

Sub test()
10 On Error Goto ERR_HANDLER
20 ' some code here
30 Exit Sub
ERR_HANDLER:
Msgbox "Error occured in line: " & Erl & vbCRLF & Err.Description
End Sub

This tool is very cool, it can also add a line numbering afterwards:
http://www.mztools.com/v3/mztools3.aspx

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Mon, 26 Jan 2009 01:01:57 +0200 schrieb tom:
the code is several hundred lines inside that one Sub CustomMailMessageRule

the question is really if there is a way when some error happens to have it tell me
why OL2003 thinks there is an error?

the error messagebox does not tell anything why or where there is some problem and as
I mentioned, days or weeks may pass without an error so I can't even force
it.
 
T

tom

Michael said:
You just need an error handler. That might look like this:

Sub test()
10 On Error Goto ERR_HANDLER
20 ' some code here
30 Exit Sub
ERR_HANDLER:
Msgbox "Error occured in line: " & Erl & vbCRLF & Err.Description
End Sub

http://www.mztools.com/v3/mztools3.aspx

I installed the tool and inserted the error handler and turned on line
numbering

Just this morning, 2 minutes ago a messagebox popped up
"Rules in Error"
Test
Ok

Apparently not so easy after all to find out what precisely is wrong.

Again, I had to manually access Rules and Alerts and check the box which
became unchecked due to the unknown error.
 
M

Michael Bauer [MVP - Outlook]

What does:

"Rules in Error"
Test
Ok

mean? Is that prompted by your code, or is your code not executed at all?

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Wed, 28 Jan 2009 17:41:15 +0200 schrieb tom:
 
T

tom

Michael said:
What does:

"Rules in Error"
Test
Ok

mean? Is that prompted by your code, or is your code not executed at all?

a non-descriptive messagebox appeared out of somewhere from OL2003

the title of the messagebox was "Rules in Error"

in the body of the messagebox is says "Test"

undeneath is a commandbox with the text "Ok"

whatever created that messagebox is clearly coming from OL2003 and not from my Sub and
the effect is that I must access Rules and Alerts and check the rule to run the code

I keep asking these questions as I don't know the answers but would love to know why
it is that I can not see where there is an error in my
Test.ThisOutlookSession.CustomMailMessageRule (Sub CustomMailMessageRule)
 
M

Michael Bauer [MVP - Outlook]

Do you have another rule called "Test"? Maybe that's the one causing the
error.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Thu, 29 Jan 2009 04:25:32 +0200 schrieb tom:
 

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