PDA

View Full Version : Macro Not Recognized with '(msg as MailItem)' parameter?



ParaDiddle
10-02-2010, 04:42 PM
I have a macro with code:

Sub KIKProc(msg as MailItem)


The problem is that I can't get it to run or debug it with the "msg as MailItem" parameter. If I remove that parameter, it runs in debug mode but then I don't know how to get the active email. I'm running his macro with a rule, so I need to pass in or get a reference to the email that the rule is being run on etc....

The macro doesn't show in my macro list with the parameter in the sub definition but it does show in my macro list without it.

Any help would be greatly appreciated. I'm using Outlook 2010.

Paul_Hossler
10-03-2010, 01:43 PM
You can't directly run (F5) or call from the Macros list (Alt-F8) if it has a parameter. How would the macro know what msg is equal to?

What are you trying to do?

Paul

ParaDiddle
10-03-2010, 02:50 PM
I'm setting up the macro/VBA to run as a rule. When I originally made the macro, I was able to run it and the selected email would come in as the parameter.

I also remember that running the rule manually on an email I marked as unread would also break into the VBA debugger tool, but it's not doing that anymore.

Am I missing something?

Charlize
10-13-2010, 06:22 AM
The idea of Sub KIKProc(msg As MailItem) is to run this one when you use rules when a mail arrives. Maybe msg is a reserved keyword. Try Sub KIKProc(mymessage As Outlook.MailItem)instead. When you want to process the mail, use mymessage to look at subject or body or whatever ...

Better check if the item is a mailitem using the class object.

Charlize