Consulting

Results 1 to 16 of 16

Thread: Solved: Want workaround for "Add reminder" from email message

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

    Solved: Want workaround for "Add reminder" from email message

    If I highlight a message in OL2003, right click, click Follow up, click "Add reminder" it does its silly flag business. Can I use a VBA routine to bring up the "add calendar entry" dialog populated with the [same] message subject?
    I just found a cool semi-advanced VBA page - dictionary, queue, etc. http://analystcave.com/excel-vba-dic...ta-structures/

  2. #2
    Knowledge Base Approver
    The King of Overkill!
    VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    Hi,

    It should be possible, though being a week old you may already have found an answer elsewhere. Are you looking to just add a button to outlook, or add an option to the right-click menu?

    Matt

  3. #3
    Hi - I'd be interested too if you've found a solution for this.

    Cheers,
    rrenis

  4. #4
    VBAX Tutor TheAntiGates's Avatar
    Joined
    Feb 2005
    Location
    Tejas
    Posts
    263
    Location
    Well, a button would be nice for accelerated keystroking, since I don't see that Outlook macros take hotkeys. But that aspect will be duck soup once I have the code. ( Too bad I can't "record a macro" and tweak from there )
    I just found a cool semi-advanced VBA page - dictionary, queue, etc. http://analystcave.com/excel-vba-dic...ta-structures/

  5. #5
    Knowledge Base Approver
    The King of Overkill! VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    If all you're looking for is the code, I think I can help with that too. If you're a keyboard enthusiast (like myself), the best way to do it in outlook is to create a menu option and use the Alt-key shortcuts with those (I'd be happy to give you more info on that if you'd like, im guessing you already know)

    In outlook2000 you can only add reminders to messages, tasks, and appointments. 2003 may be different (it looks like they can be set for contacts too, so you may not need my Select Case statement). Take a look at the following:[vba]Sub CreateReminder()
    Select Case TypeName(Application.ActiveExplorer.Selection(1))
    Case "MailItem", "TaskItem", "AppointmentItem"
    With Application.ActiveExplorer.Selection(1)

    'Add a reminder to the current item
    .ReminderSet = True

    'Set the time for the reminder (I wrote the relative to the current time
    ' if you want them to be a specific day/time, you can set it directly too)
    .ReminderTime = Now + 1 '1 day
    'or
    .ReminderTime = Now + TimeValue("01:00:00") '1 hour from now

    'Need to save changes or it wont stick
    .Save

    End With
    End Select
    End Sub[/vba]I first check to see if its one of the types that can use reminders, I then set the ReminderSet to true (adds reminder), then set the time (I give a couple examples of how, feel free to ask questions if you're confused about it), then save the item.

    I'd be happy to help you impliment it or do anything else, just thought you only wanted the 'guts' of the code.

    I completely agree that it sucks you cant record a macro in outlook. Luckily the help files are still decent (and theres always here or outlookcode.com for extra help)

    Matt

  6. #6
    Knowledge Base Approver
    The King of Overkill! VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    Ok, I apparently skipped over this line today:
    Can I use a VBA routine to bring up the "add calendar entry" dialog populated with the [same] message subject?
    I'll get that in a sec

  7. #7
    Knowledge Base Approver
    The King of Overkill! VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    With variable type declaration (so you can see the properties/etc in vba if you want to play around):[vba]Sub AddCalendarEntry()
    Dim vMI As MailItem, AI As AppointmentItem
    If TypeName(Application.ActiveExplorer.Selection(1)) <> "MailItem" Then Exit Sub
    Set vMI = Application.ActiveExplorer.Selection(1)
    Set AI = Application.CreateItem(olAppointmentItem)
    With AI
    .Subject = vMI.Subject
    .Display
    End With
    End Sub[/vba]

    Barebones:[vba]Sub AddCalendarEntry()
    If TypeName(Application.ActiveExplorer.Selection(1)) <> "MailItem" Then Exit Sub
    With Application.CreateItem(olAppointmentItem)
    .Subject = Application.ActiveExplorer.Selection(1).Subject
    .Display
    End With
    End Sub[/vba]

  8. #8
    VBAX Tutor TheAntiGates's Avatar
    Joined
    Feb 2005
    Location
    Tejas
    Posts
    263
    Location
    Very nice. Thank you!

    BTW I used the earlier idea you presented, adding

    .Start = Now + TimeValue("01:00:00") '1 hour from now
    I just found a cool semi-advanced VBA page - dictionary, queue, etc. http://analystcave.com/excel-vba-dic...ta-structures/

  9. #9
    Knowledge Base Approver
    The King of Overkill! VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    That is a good idea.. though I was quite excited to see (after writing the first code here) that I could add reminders without the flag, a kind of covert reminder (i dont know of a way I can access them, they kinda just surprise me now )

  10. #10
    VBAX Tutor TheAntiGates's Avatar
    Joined
    Feb 2005
    Location
    Tejas
    Posts
    263
    Location
    One more queer thing. It SEEMS that the only way to accelerate the new menu item is by ampersanding the FIRST letter - not the second or anything. A&ddCalendarEntry just laughs at me when I press alt-D.
    I just found a cool semi-advanced VBA page - dictionary, queue, etc. http://analystcave.com/excel-vba-dic...ta-structures/

  11. #11
    Knowledge Base Approver
    The King of Overkill! VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    Interesting.. can't say I ever noticed that before.

    For fun I just ran:[vba]Sub AddAButton()
    Dim CB As CommandBar
    Set CB = Application.ActiveExplorer.CommandBars("Menu Bar")
    With CB.Controls.Add(msoControlPopup, Before:=CB.Controls.Count + 1, Temporary:=True)
    .Caption = "&BCD"
    .OnAction = "MsgboxHi1"
    End With
    With CB.Controls.Add(msoControlPopup, Before:=CB.Controls.Count + 1, Temporary:=True)
    .Caption = "B&CD"
    .OnAction = "MsgboxHi2"
    End With
    With CB.Controls.Add(msoControlPopup, Before:=CB.Controls.Count + 1, Temporary:=True)
    .Caption = "BC&D"
    .OnAction = "MsgboxHi3"
    End With
    End Sub
    Sub MsgboxHi1()
    MsgBox "hi 1"
    End Sub
    Sub MsgboxHi2()
    MsgBox "hi 2"
    End Sub
    Sub MsgboxHi3()
    MsgBox "hi 3"
    End Sub[/vba]And alt-b brings up the msgbox, but alt-c or alt-d require me to press enter afterwards to trigger it...

    After a little more look I realized my "Send/Receive" button uses C, and "Delete" uses D..
    after changing it to:[vba]Sub AddAButton()
    Dim CB As CommandBar
    Set CB = Application.ActiveExplorer.CommandBars("Menu Bar")
    With CB.Controls.Add(msoControlPopup, Before:=CB.Controls.Count + 1, Temporary:=True)
    .Caption = "&BGI"
    .OnAction = "MsgboxHi1"
    End With
    With CB.Controls.Add(msoControlPopup, Before:=CB.Controls.Count + 1, Temporary:=True)
    .Caption = "B&GI"
    .OnAction = "MsgboxHi2"
    End With
    With CB.Controls.Add(msoControlPopup, Before:=CB.Controls.Count + 1, Temporary:=True)
    .Caption = "BG&I"
    .OnAction = "MsgboxHi3"
    End With
    End Sub[/vba]All 3 worked on the first hit. Looks like you're gonna have to go with AddCalendarEntr&y

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

  13. #13
    [VBA]Sub CreateReminder()
    Select Case TypeName(Application.ActiveExplorer.Selection(1))
    Case "MailItem", "TaskItem", "AppointmentItem"
    With Application.ActiveExplorer.Selection(1)

    'Add a reminder to the current item
    .ReminderSet = True

    'Set the time for the reminder (I wrote the relative to the current time
    ' if you want them to be a specific day/time, you can set it directly too)
    .ReminderTime = Now + 1 '1 day
    'or
    .ReminderTime = Now + TimeValue("01:00:00") '1 hour from now

    'Need to save changes or it wont stick
    .Save

    End With
    End Select
    End Sub
    [/VBA]

    Just a little concern, can we input the reminder time period instead of fixing it?

  14. #14
    Knowledge Base Approver
    The King of Overkill! VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    Sure, but wouldn't that really be the same as just manually adding a reminder?

    [vba].ReminderTime = Now + TimeValue( _
    InputBox("Please enter reminder time in ""hh:mm:ss"" form."))[/vba]I didn't add any kind of error checking in there, so entering text or blank or anything will probably cause a type mismatch error I believe.
    Matt

  15. #15
    VBAX Tutor TheAntiGates's Avatar
    Joined
    Feb 2005
    Location
    Tejas
    Posts
    263
    Location
    Matt, in general assign InputBox output to a string. I can't test right now but you can check if Outlook operates like (AFAIK all of) the rest of Office:[vba]
    dim sResponse as string
    sResponse=InputBox("Enter something")
    if sResponse="" then exit sub
    [/vba]Then convert using cdbl, cdate, etc. The test nicely captures the escape key.

    I usually also use the other InputBox argument to seed a likely (default) response, so user can quickly just hit the Enter or Escape key as often as possible.
    I just found a cool semi-advanced VBA page - dictionary, queue, etc. http://analystcave.com/excel-vba-dic...ta-structures/

  16. #16
    Knowledge Base Approver
    The King of Overkill! VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    Yeah I was going to put that in there, but then also thought I should split it by ":" to make sure HH and MM and SS were added and everything, so I just decided to go with no error checking (since I thought the point of this was for less user interaction when adding a reminder )
    Matt

Posting Permissions

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