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?
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/
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
Hi - I'd be interested too if you've found a solution for this.
Cheers,
rrenis
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/
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
Ok, I apparently skipped over this line today:I'll get that in a secCan I use a VBA routine to bring up the "add calendar entry" dialog populated with the [same] message subject?
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]
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/
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 )
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/
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
haha - thanks
I just found a cool semi-advanced VBA page - dictionary, queue, etc. http://analystcave.com/excel-vba-dic...ta-structures/
[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?
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
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/
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