none
Macro is not available to run RRS feed

  • Question

  • I found the macro below to "Run Rules on demand" and modified it to my specifications. However, it does not show up in the Macros dialog box and I cannot run it from the VBA window (just nothing happens). What am I missing? [Office 2016 365]

    Sub RunRules(Item As Outlook.MailItem)
    
    Dim olRules As Outlook.Rules
    Dim myRule As Outlook.Rule
    Dim olRuleNames() As Variant
    Dim name As Variant
    
    ' Enter the names of the rules you want to run
    olRuleNames = Array("Yielding report", "Daily Flash Report", "Hot Card")
    
    Set olRules = Application.Session.DefaultStore.GetRules()
    
    For Each name In olRuleNames()
        For Each myRule In olRules
        ' Rules we want to run
            If myRule.name = name Then
            myRule.Execute ShowProgress:=True
            End If
        Next
    Next
    End Sub

    Friday, July 5, 2019 10:28 PM

All replies

  • Hi,

    Based on your description, your question is mainly related to using VBA in Outlook. To help you better resolve the issue, I will move the thread to Office for developersOutlook for Developers forum. You may get more helpful replies there.

    Thanks for your kind understanding.

    Best Regards,

    Herb


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Office 2019.


    Monday, July 8, 2019 1:54 AM
  • Hello,

    First of all, make sure that VBA macros are enabled and can be run (see the Trust center settings).

    I think that is because you still use a sub with a parameter. Typically such methods are assigned to and invoked by rules.

    Sub RunRules(Item As Outlook.MailItem)


    But I'd recommend using a public sub without params:

    Public Sub RunRules()



    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Monday, July 8, 2019 10:27 AM