When writing automation for certain processes, it is sometimes important to set a follow-up reminder appointment for the next step. For this task, I wrote a very simple script that sets a reminder in Outlook.
This script is super simple and can be improved several different ways. For simplicity sake, I decided to leave out the fancy “With” procedure and just use the object reference. Also, to provide feedback to your app, this function evaluates to “true” once your reminder has been set.
'Before using this function, you must add a reference
'to your version of the Microsoft Outlook Object
'Library or you will encounter errors.
''''''''''''''''''''''''''''''''''''
Function makeReminder(rDate As Date) As Boolean
Dim ol As Outlook.Application, item As AppointmentItem
Set ol = New Outlook.Application
Set item = ol.CreateItem(olAppointmentItem)
'Set the reminder for 8:30 am on input date
item.Start = rDate + TimeValue("8:30")
'Set one hour duration
item.Duration = 60
'appointment subject
item.Subject = "Write your fancy subject line here"
'location description
item.Location = "Somewhere over there"
'body message
item.Body = "What in the world are you doing at this time?"
'set the busy status
item.BusyStatus = olBusy
'reminder before start
item.ReminderMinutesBeforeStart = 15
'reminder activated
item.ReminderSet = True
'duh! save the thing!
item.Save
'garbage collection - kind of...
Set ol = Nothing
Set item = Nothing
'return true
makeReminder = True
End Function
Test Outlook Appointment VBA Script
To test this script, here is an example:
Sub testThing()
Dim rDate As Date
'set date
rDate = InputBox("start")
If makeReminder(rDate) = True Then
MsgBox "Reminder Set"
Else
MsgBox "Oy! Something is a miss"
End If
End Sub
So there it is! My obviously simple Outlook Appointment setting function. That being said, this demo was created to be a simple framework for what the object can do. If you use this, please post a comment about how you used it and any extra features you used.
Works perfectly. Thanks so much for posting this. I have been trying to sort this out for days now. I am using to this code to schedule project tasks based off a known start date. So from the one date I calculate 7 different task due dates and inserts them in to my calendar with one click. Saves me tons of time.
Hello, I have a problem using this script. When a compile the VBA project, the program shows me a message box with this information: “Compilation Error: The type defined by the user it hasn’t been defined”, do you know what is solution for this?
Sounds like you are missing a reference to the MS Outlook library. Check your references.
Yes, thank you! So many of these just don’t work and it’s frustrating to those trying to learn. Even the one on Microsoft’s site doesn’t work as they use application.createItem which is incorrect. Thanks again!
Hey,
Thanks for this code it helps me a lot but i’m still working on something. I want to add people to the appointment. The appointments i want to make are not for me alone. So i added the next line:
item.RequiredAttendees = “fake@emailadress.com”
item.send
But it add the person to the appointment but it doen’st send a invite. How can i build this in?
You’ll need to set the meeting status to get the message to set automatically.
item.MeetingStatus = olMeeting