Consulting

Results 1 to 4 of 4

Thread: How to code to trigger rule

  1. #1
    VBAX Tutor TheAntiGates's Avatar
    Joined
    Feb 2005
    Location
    Tejas
    Posts
    263
    Location

    How to code to trigger rule

    I'd like code to toggle one particular hardcoded rule (and I'm greedy - I'd like a hotkey). Even greedier of me, but of great value, would be a timer that starts when Outlook application begins, and fires the aforementioned code after 0 seconds and then after 60 seconds (that way my treasured fingernail-filing is not rudely interrupted by having to hit the key, naturally).

    The idea is to suppress a particular rule that is particularly annoying - it starts a new item alert window whenever any new mail arrives. This is fine in the middle of the day (actually, vital, because just the tiny taskbar envelope and temporary transparent guy are not enough to grab my attention). But (e.g.) upon Monday morning Outlook startup, when my eagerly awaited 80 Viagra and weight loss offers arrive, my whole PC is temporarily useless - sometimes for a full minute or more. When my new item rule is running, every one second or so, the New Item window grabs focus. This is what I'd like simple toggle control over (and instantaneous - ergo hotkey, or automatic "timered" invocation).

    Yes, I could manually turn the rule "off" and "on" but AFAICT that's far too much work if a code solution is available. Besides, I'm not sure I could, competing against the "focus eating monster." (One more item that might be useful to my arsenal would be command line syntax for rule suppression/invocation, tweaking the [XP] shortcut file.)

    I am versed in VBA and use it extensively in Excel, Access and Word, but never yet in Outlook, so pointing me to a FAQ or KB on basics of VBA for OUTLOOK might not hurt. I can find alt-F11 okay, but that's about it; I have no knowledge of Outlook events. But as to particulars, like varying the rule name above, or the 60, evil hardcoding is fine for now, and I can be creative with that later with menus or config file or whatever.

    As to the object name of the particular rule, I'm wondering if there is something like Rules("All New to Item Alert Window"). I say this because all I have right now to go by is the "friendly" name of the rule - i.e. what's initially visible when you go alt-T, L (from Inbox).

    TIA.
    I just found a cool semi-advanced VBA page - dictionary, queue, etc. http://analystcave.com/excel-vba-dic...ta-structures/

  2. #2
    VBAX Tutor TheAntiGates's Avatar
    Joined
    Feb 2005
    Location
    Tejas
    Posts
    263
    Location
    I have everything I need - except the code to enable the rule.[vba]'module:
    Option Explicit
    Public Declare Function SetTimer Lib "user32" (ByVal hWnd As Long, ByVal _
    nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
    Public Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, ByVal _
    nIDEvent As Long) As Long
    Sub TurnOnItemAlerts(ByVal hWnd As Long, ByVal uMsg As Long, _
    ByVal nIDEvent As Long, ByVal dwTimer As Long)
    KillTimer 1&, nIDEvent
    'RIGHT HERE - what I need
    End Sub

    'ThisOutlookSession
    Option Explicit
    Sub Application_Startup()
    SetTimer 0&, 1&, 60000&, AddressOf TurnOnItemAlerts 'timer 1 - 60 seconds
    End Sub
    [/vba]
    Last edited by TheAntiGates; 11-29-2006 at 03:47 PM.
    I just found a cool semi-advanced VBA page - dictionary, queue, etc. http://analystcave.com/excel-vba-dic...ta-structures/

  3. #3
    VBAX Tutor
    Joined
    May 2004
    Location
    Germany, Dresden
    Posts
    217
    Location
    Good to see another person seeking the same thing. I'm trying something similar (fire a defined rule from VBA-Code), but was not even able to find a way to "talk" to rules in VBA in general.
    So if there's any update on that matter, I'm eager to hear about it!

    Daniel

  4. #4
    VBAX Tutor TheAntiGates's Avatar
    Joined
    Feb 2005
    Location
    Tejas
    Posts
    263
    Location
    Bumpus threadus
    I just found a cool semi-advanced VBA page - dictionary, queue, etc. http://analystcave.com/excel-vba-dic...ta-structures/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •