none
Outlook 2010 - VBA Code to Fire Multiple Tasks at Different Times RRS feed

  • Question

  • Under the Outlook "ThisOutlookSession", I have the following VBA Code:

    Private Sub Application_Reminder(ByVal Item As Object)
    If Item.Subject = "E-Mail Sales Report" Then

    EMAILREPORTS

    If Item.Subject = "E-Mail Sales Report" Then
          Item.Delete
    End If 'Ends If DELETE REMINDER Item.Subject - "E-Mail Sales Report"

    End If 'Ends If Item TASK LAUNCHER IF ITEM.SUBJECT = "E-MAIL SALES REPORT"

    End Sub

    ************************************

    I have a Task Item set-up with a reminder that gets reset daily located in the EMAILREPORTS sub code.

    What I'm attempting to do, is add other reminders (i.e. weekly, monthly, etc) to fire different task for which I would be creating other sub-codes to accomplish the necessary tasks.

    The issue I'm having is I can't find a way for another reminder, i.e. Monthly Reports, to be triggered.  It appears that I can only set one reminder.  I attempted this by doing another If Item.Subject = "Monthly Reports", then..... etc.

    Is there a method in VBA to CHOOSE one of multiple scenarios based on the Item.Subject? Something like:

    E-Mail Sales Report call EMAILREPORTS

    Monthly Report call MonthlyReports

    Any help would be appreciated on this.

    Thanks.

    JMData Consultant

    Tuesday, July 30, 2013 1:45 PM

Answers

  • Final Code that works:

    Select Case Item.Subject
        Case Is = "E-Mail Sales Report"
       
            EMAILREPORTS
           
            If Item.Subject = "E-Mail Sales Report" Then
                Item.Delete
            End If

        Case Is = "Test"
        
            test
            If Item.Subject = "Test" Then
                Item.Delete
            End If
           
    End Select

    End Sub

    Tuesday, July 30, 2013 3:52 PM

All replies

  • Continued searching the internet for more information after posting previous entry. 

    I think what I may be looking for is a CASE Statement to say if the Item Task is A - Do 1, if B Do 2, etc.

    Does this sound right to the more experience VBA personnel??

    Thanks.

    JMData Consultant

    Tuesday, July 30, 2013 2:33 PM
  • Either a Case block, or If...ElseIf...Else...End If block. You can use as many ElseIf clauses as needed before a catch-all Else.


    Ken Slovak MVP - Outlook

    Tuesday, July 30, 2013 2:42 PM
    Moderator
  • Final Code that works:

    Select Case Item.Subject
        Case Is = "E-Mail Sales Report"
       
            EMAILREPORTS
           
            If Item.Subject = "E-Mail Sales Report" Then
                Item.Delete
            End If

        Case Is = "Test"
        
            test
            If Item.Subject = "Test" Then
                Item.Delete
            End If
           
    End Select

    End Sub

    Tuesday, July 30, 2013 3:52 PM