Run a Script Rule doesn't work

Status
Not open for further replies.

lynxus

New Member
Outlook version
Outlook 2010 32 bit
Email Account
IMAP
Hello,

first of all I hope this question hasn't been answered before and I'm in the right place here, been sitting on this problem for hours...

I am trying to run the script from this link together with a rule. The script works fine without the "Public Sub OpenLinks(olMail As Outlook.MailItem)" but without it, it doesn't show up in the script list when creating a rule. Everytime I try to run the code with "Public Sub" at the beginning nothing happens and a window pops up asking me to create a new macro (see attached picture).

I have the trust settings set to low and am running the code in a module, no other macros installed. Does anybody know how to solve this problem? Thanks in advance.
 

Attachments

  • Unbenannt.PNG
    Unbenannt.PNG
    36.8 KB · Views: 676
Did you Save the project? Sometimes the macros won't show up in run a script until you click Save in the VBA Editor.
None of the text is red?

paste this in the module and see if it shows up in the rules list. (It does nothing - i just want to see if it shows up.)
Code:
Public Sub TestMacro(olMail As Outlook.MailItem)
End Sub
 
Thank you for your reply!

Your TestMacro does show up. Also I had saved my macro (with "Public Sub") and it shows up in the scripts lists, should have mentioned this in the start post. The problem is, that the macro does show up, but does nothing and can't be run via the green test button (asking me to create a new macro as in the picture) or when i send myself a test email. If i just start with "Sub OpenLinks()" it works flawlessly, but cannot be assigned to a rule (doesn't show up in the list).
 
This part is required to use in a rule: olMail As Outlook.MailItem. olMail references the message and can be any variable - but it needs to match how the message is referenced in the code: If Reg1.test(olMail.Body) Then.

Oh... now i understand. Run a script rules aren't visible in the list of macros, only in the list when you set up a rule. You can't run them manually. I use a small stub macro to set the message (represented by olMail in this macro) so i can test it outside of a rule.

use this stub to run it manually - select a message and run this macro - it will call the openlinks macro and pass the selected message to it, just like a rule would do with an incoming message.

Code:
Sub RunScript()
Dim objApp As Outlook.Application
Dim objItem As MailItem
Set objApp = Application
Set objItem = objApp.ActiveExplorer.Selection.Item(1)

'macro name you want to run goes here
OpenLinks objItem

End Sub
 
I'm a bit out of the loop now. Maybe it helps if i state what exactly i want to do (VBA newbie here).
My goal is to open all hyperlinks in new incoming unread emails automatically when they arrive in the folder. Therefore i tried to set up a rule, that starts the OpenLinks-Script everytime a new message arrives. Is this even possible?

I tried your RunScript but don't know exactly where to put it and what to do with it, I'm not a native speaker and have some trouble understanding the context. Once again thanks for your help though, maybe you got a (different) solution for what I'm trying to do!
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
K Run a script rule to auto 'send again' on undeliverable emails? Outlook VBA and Custom Forms 1
G Save attachment run a script rule Outlook VBA and Custom Forms 0
E Having some trouble with a run-a-script rule (moving mail based on file type) Outlook VBA and Custom Forms 5
B Outlook rule run a Script doesn't work Outlook VBA and Custom Forms 1
Bri the Tech Guy Run Script rule not running for newly arriving messages Outlook VBA and Custom Forms 25
Vijay Error in rule- Run a script Using Outlook 1
Diane Poremsky Run a Script Rule: Send a New Message when a Message Arrives Using Outlook 2
L Cannot run script from rule Outlook VBA and Custom Forms 7
O modify vba to run it as script rule Outlook VBA and Custom Forms 8
Jeff Rott Diane Question on "Use in a Run a Script Rule" Outlook VBA and Custom Forms 1
L Run script rule not exectued for first few mails Outlook VBA and Custom Forms 2
J Outlook Rules VBA Run a Script - Multiple Rules Outlook VBA and Custom Forms 0
N Outlook 2021 'Run Script" Rules? Outlook VBA and Custom Forms 4
Aussie Rules Run a Script on an Incoming Email OK and then the Email reverts Outlook VBA and Custom Forms 0
Y Outlook 2013 Run A Script Outlook VBA and Custom Forms 4
B Wanting to run a script that will filter any body that has a russian link in it. Outlook VBA and Custom Forms 5
Bri the Tech Guy Registry Tweak to make "Run a Script" Action Available Outlook VBA and Custom Forms 2
Vijay Run script doesn't work in outlook Using Outlook 1
oliv- How to Run a Script IN AN ADDIN with Outlook's Rules and Alerts Outlook VBA and Custom Forms 2
X Outlook script to run excel data Outlook VBA and Custom Forms 1
D RUN SCRIPT WHEN OUTLOOK IS CLOSE Outlook VBA and Custom Forms 1
P How many subs can run in one outlook VBA script Using Outlook 5
Xueying run a script in rules, first time succeed, failed afterwards Outlook VBA and Custom Forms 3
P Vba script including macro appears in rules but wont run Outlook VBA and Custom Forms 6
J Outlook 2007 Rules & VBA: How to run a script on a report message (ReportItem) Using Outlook 14
L Outlook 2007 Macro to Run a Script From a Contact Form Using Outlook 41
B The “run a script” function stopped unexpectedly in Outlook2007 Using Outlook 6
E run script fails suddenly Using Outlook 3
L Run A Script not listed in rules wizard Outlook VBA and Custom Forms 12
X Run macro automatically when a mail appears in the sent folder Using Outlook 5
V Outlook macros no longer run until VB editor is opened Outlook VBA and Custom Forms 0
J Want to create a button on the nav bar (module add-in) to run code Outlook VBA and Custom Forms 2
T Outlook 2010 Errore run-time -2147417851 (80010105) Metodo delete ContactItem non riuscito Outlook VBA and Custom Forms 0
U Outlook 2019 VBA run-time error 424 Outlook VBA and Custom Forms 2
D Outlook 2013 Macros only run in VB editor, not in drop down or button Outlook VBA and Custom Forms 14
D We're sorry but outlook has run into an error Using Outlook 6
M White square in body of Outlook Messages (O2016 Version 2012 32bit Click To Run) Using Outlook 4
C Auto Run VBA Code on new email Outlook VBA and Custom Forms 1
A Apply Selected Emails to outlook rules and Run Rules Using Outlook 5
B VBScript doesn't run on Recipient Email Outlook VBA and Custom Forms 2
A Run-time error '430' on certain emails when trying to set "Outlook.mailitem" as "ActiveExplorer.Selection.Item" Outlook VBA and Custom Forms 2
S Outlook Custom Form Scripting only working when clicking on "Run this form" Outlook VBA and Custom Forms 2
O Outlook 2016 This rule will only run when you check your email in Outlook.... Using Outlook 4
B run scripts Using Outlook 1
A Run time error 424. object required in outlook 2013 Outlook VBA and Custom Forms 10
Dave A Run macro on existing appointment when it changes Outlook VBA and Custom Forms 1
O Run macro automatically at sending an email Using Outlook 11
P errors appear every time I run SCANPST Using Outlook 3
S VBA Macro - Run-time error '424': object required - Help Please Outlook VBA and Custom Forms 3
P Run Time Error 91 when linking contact to task in VBA Outlook VBA and Custom Forms 1

Similar threads

Back
Top