Created
December 14, 2015 12:02
-
-
Save jangins101/168a1ee9cbd7c52162ab to your computer and use it in GitHub Desktop.
VBA script for Outlook to simplify running a single rule
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Rule execution | |
Sub RunRule(rulename As String) | |
Dim st As Outlook.Store | |
Dim myRules As Outlook.Rules | |
Dim rl As Outlook.Rule | |
Dim RunRule As String | |
Set st = Application.Session.DefaultStore | |
Set myRules = st.GetRules | |
For Each rl In myRules | |
If rl.RuleType = olRuleReceive Then | |
If rl.Name = rulename Then | |
rl.Execute ShowProgress:=True | |
RunRule = rl.Name | |
Exit For | |
End If | |
End If | |
Next | |
ruleList = "Rule '" & RunRule & "' completed" | |
MsgBox ruleList, vbInformation, "Macro: RunRule" | |
Set rl = Nothing | |
Set st = Nothing | |
Set myRules = Nothing | |
End Sub | |
' Set a Macro shortcut on the toolbar to a function like this | |
Sub RunRule_SuperAwesomeRule() | |
RunRule ("MySuperAwesomeRule") | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment