View Single Post
 
Old 02-23-2013, 09:50 AM
niton niton is offline Windows 7 64bit Office 2012
Competent Performer
 
Join Date: Jul 2012
Posts: 102
niton is on a distinguished road
Default

http://www.outlookcode.com/threads.a...essageid=28707

As indicated in the link above, for Outlook 2007 and subsequent.

Code goes in the "ThisOutlookSession" module.

To turn the rule off at startup.

Code:
Private Sub Application_Startup()
    Dim olRules As Outlook.Rules
    Dim olRule As Outlook.Rule

    Set olRules = Application.Session.DefaultStore.GetRules
    Set olRule = olRules.Item("Rule Name")
    olRule.Enabled = False

    olRules.Save

    Set olRules = Nothing
    Set olRule = Nothing
End Sub
To turn the rule on when quitting Outlook.

Code:
Private Sub Application_quit()
    Dim olRules As Outlook.Rules
    Dim olRule As Outlook.Rule

    Set olRules = Application.Session.DefaultStore.GetRules
    Set olRule = olRules.Item("Rule Name")
    olRule.Enabled = True

    olRules.Save

    Set olRules = Nothing
    Set olRule = Nothing
End Sub
Reply With Quote