VBA: Flag msg w/default time but NO start & end dates & reminder for today with set time (and what would we do for default time)? RRS feed

  • Question

  • For some reason, had to re-create my account, so to speak and I couldn't reply to my own message from way back when that never got a resolution but that I've struggled with since then, ending up doing it manually most of the time.  So begging the group's indulgence in re-posting the same question as it was never resolved.

    As I mentioned in my original message in 2014, I needed to be able to set a reminder flag via vba but with conditions that I've not found an answer for though others have asked the same or very similar question.  None of us seem to have ever resolved this, so hoping this time it's different.  It's hard to describe, so if anyone here would be so kind, if you open an email message and then open the custom flag dialogue box first, that might be the easiest way to see the problem.  i.e., one of the answers to this flag question involved someone kindly but erroneously giving an appointment solution when this is not about an appointment but about a reminder custom flag, that we can set to email messages so that we can make sure we do a certain action by a certain time for said email.  Thanks!

    In the custom flag dialogue box there are 5 fields:

    1.  Flag to:  - this is the message, i.e., the default is FOLLOW UP

    2.  Start Date: - I _never_ need a date here.  It complicates things.  This is a reminder flag, not something for me to track start and due dates.

    3.  Due Date: - as explained above, this is always set to NONE.

    4. Reminder:  - DATE

    5. Reminder: - TIME

    So the vba should give:

    1. Flag message, either leave as is or a custom message.

    2. Start Date:  BLANK

    3. Due Date:  BLANK

    4. Reminder (date):  Today's date

    5. Reminder (time):  16:25

    6.  And the dialogue box should remain open.

    I've not resolved this but I have achieved the above partially to this degree - 1. flag message, okay.  2. Start date is blank. 5. Reminder time is 4:25 p.m.

    The rest I haven't managed.  I need to fix:

    3.  Due Date:  Blank

    4. Reminder date - today's date.

    6. Dialogue box remains open.

    What I have cobbled together from a great number of posts is this:

    Public Sub FLAG_Message_CUSTOM()
    Dim objMsg As Object
    ' GetCurrent Item function is at
    Set objMsg = GetCurrentItem()   ' the GetCurrentItem option is found below.
    With objMsg
    ' START DATE field?
        .MarkAsTask olMarkNoDate
    '  DUE DATE field:
        .TaskDueDate = Now()   'what is syntax for no date like above .MarkAsTask's NO DATE.  Nothing here worked!
    '    .FlagRequest = "Follow up at Day's End"
    '    .FlagRequest = "Email from: " & objMsg.SenderName
        .FlagRequest = "Task:"     ' flag message goes here, i.e., "Follow up"
        .ReminderSet = True
        .ReminderOverrideDefault = True
        .ReminderTime = " 16:25:00 PM"
        .ReminderSet = True
    '    .Save
    End With
    Set objMsg = Nothing
    End Sub
    ' 170525.Th, 15h45:
    '                    GetCurrentItem - called from above FLAG macro.
    Function GetCurrentItem() As Object
        Dim objApp As Outlook.Application
        Set objApp = Application
        On Error Resume Next
        Select Case TypeName(objApp.ActiveWindow)
            Case "Explorer"
                Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
            Case "Inspector"
                Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
        End Select
        Set objApp = Nothing
    End Function

    If some kind soul could help with the 3 items that I haven't been able to figure out (make DUE DATE blank, set reminder DATE to today, and leave the custom flag dialogue box OPEN), that would be grand and would finally put this 3-year old problem to rest!

    Thank you!

    Thursday, May 25, 2017 8:57 PM

All replies

  • Hello,

    >>3.  Due Date:  Blank

    If you want to let Start Date and Due Date keep blank,  we must use 

     .MarkAsTask olMarkNoDate

    You could make them blank manually from Outlook UI, then you could find Outlook flags it as No Date.

    >>4. Reminder date - today's date.

    Please use

        .ReminderTime = Date & " 16:25:00 PM"

    "Date" would return today's date

    >>6. Dialogue box remains open.

    We could use CommandBars.ExecuteMso Method to show the dialog

      Select Case TypeName(Application.ActiveWindow)
            Case "Explorer"
                ActiveExplorer.CommandBars.ExecuteMso ("AddReminder")
            Case "Inspector"
                ActiveInspector.CommandBars.ExecuteMso ("AddReminder")
        End Select



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Friday, May 26, 2017 2:20 AM