vbaoutlookoutlook-2013office-2013

open/execute Outlook's Custom flag dialog popup with VBA


Within Outlook 2013, if you want to add a custom flag to an item you get this dialog:

enter image description here

I am trying to figure out how to open this dialog using VBA? I can either open it for a selected e-mail item or if there is a way to open it directly and retrieve the date/data the user selected.


Solution

  • You can simulate pressing buttons with ExecuteMso

    Private Sub AddReminderDialog_ExecuteMso()
    
        Dim objItem As Object
    
        On Error Resume Next
        Set objItem = ActiveInspector.currentItem
        On Error GoTo 0
    
        If Err <> 0 Then
            ActiveInspector.CommandBars.ExecuteMso ("AddReminder")
        Else
            ActiveExplorer.CommandBars.ExecuteMso ("AddReminder")
        End If
    
    End Sub
    

    You can see the "AddReminder" when you hover over the button when adding to the Quick Access Toolbar or a ribbon.