Outlook VBA, Macros not appearing in "Run a script" menu

bamblack

Board Regular
Joined
Aug 15, 2011
Messages
208
Hi all,

I've written a bit of code:

Code:
Option Explicit
Sub Run(msg As MailItem)

'Miscellaneous code here

End Sub

However, when I try to set up a rule so that it will run this code when a certain email is received, the subroutine isn't showing up in the "Run a script" menu. I have the code saved in it's own standard module. I've been trying to figure it out for the past hour or so and haven't been able to make any headway on it. I'm just jumping into Outlook VBA, so any suggestions on how to fix it would be greatly appreciated!
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
If I add that code to a module it appears in the list when I click the Script link in the Rules Wizard. Which version of Outlook?
 
Upvote 0
Curious. It works fine in 2010. I'll see if it's a known issue.
 
Upvote 0
Also something that may be of note, none of the modules I've written are appearing in the Run menu when I press F5 inside the VBE. However, if I write a test module and just say

Code:
Sub Run

'Code Here

End Sub

It shows up fine in the VBE Run menu, but not in the Run a script menu. I'm really going loopy over here trying to figure this one out.
 
Upvote 0
The procedure declaration has to be specific (taking a mailitem or appointmentitem argument) for the procedure to appear in the run a script section.
Wild thought - you haven't used the same name for the module as you did for the routine?
 
Upvote 0
Nope, different names for module/sub. And I remember reading that somewhere, I just figured it had to be there to appear in either. I've even gone to the point of running Office Diagnostics, but it didn't find anything.
 
Upvote 0
I figured it out, when you said same name for module/routine, it got me to thinking. I have two modules, each with one sub and both subs were named "Run". I changed the name of one of them and voila, they appeared!
 
Upvote 0
Having the same problem but not for the same reason apparently. In the VBA IDE I have 2 modules, module1 & module2. They each have differently named subroutines which use type MailItem. If I go into rules in Outlook both the subroutines show up. But if I press F5 in the IDE or select Tools, Macros from the menu, they are not listed even though even though the Project listed in the “Project In” box is correct. Very frustrating. Help very appreciated. Thanks!
 
Upvote 0
You can't run a macro that requires arguments using f5, and they won't appear in the macro dialog box, since neither method would allow you to pass a mailitem to the routine.
 
Upvote 0

Forum statistics

Threads
1,225,613
Messages
6,186,004
Members
453,334
Latest member
Prakash Jha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top