• Skip to main content
  • Skip to primary sidebar

Ryan McCormick

Dedicated Dad, Software Engineer and Lover of Coffee

Set Appointment in Outlook With VBA in Access or Excel 2010, 2013

March 26, 2014 by Ryan McCormick 6 Comments

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.

Related

Filed Under: VBA Tagged With: access, Excel, outlook appointment, vba

Reader Interactions

Comments

  1. Michael says

    March 25, 2015 at 2:47 pm

    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.

    Reply
  2. Edson says

    January 6, 2017 at 8:07 pm

    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?

    Reply
    • Ryan McCormick says

      March 19, 2017 at 4:02 pm

      Sounds like you are missing a reference to the MS Outlook library. Check your references.

      Reply
  3. John says

    April 3, 2017 at 10:45 am

    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!

    Reply
  4. Frank says

    May 30, 2017 at 4:55 am

    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?

    Reply
  5. Guy Incognito says

    November 2, 2017 at 10:03 am

    You’ll need to set the meeting status to get the message to set automatically.

    item.MeetingStatus = olMeeting

    Reply

Leave a Reply Cancel reply

Primary Sidebar

Recent Posts

  • Force Quit Kill all Chrome Windows MacOS
  • SOLVED: Angular 6 CLI Karma Stuck in Single Run | Karma Stops Running
  • How to Manually Install Java 8 on Ubuntu 18.04 LTS
  • Remove VirtualBox from Ubuntu 16.04 Xenial
  • Clear all Node Modules Folders Recursively Mac/Linux

Recent Comments

  • KKV on Webstorm adding spaces between imports and braces | JavaScript and TypeScript
  • jusopi on Clear all Node Modules Folders Recursively Mac/Linux
  • Qaisar Irfan on Clear all Node Modules Folders Recursively Mac/Linux
  • mustafa on Remove VirtualBox from Ubuntu 16.04 Xenial
  • Pourya on How to Manually Install Java 8 on Ubuntu 18.04 LTS

Archives

  • May 2019
  • May 2018
  • April 2018
  • March 2018
  • January 2018
  • September 2017
  • August 2017
  • July 2017
  • June 2017
  • March 2017
  • December 2015
  • November 2015
  • July 2015
  • April 2015
  • February 2015
  • September 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014
  • October 2013
  • August 2013
  • June 2013
  • April 2013
  • March 2013
  • February 2013
  • December 2012
  • October 2012
  • September 2012
  • August 2012
  • July 2012
  • May 2012
  • March 2012
  • February 2012
  • December 2011
  • November 2011
  • April 2011
  • March 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • August 2009
  • July 2009
  • May 2009

Categories

  • Angular
  • Angular 2
  • AngularJS (1x branch)
  • Computer Q&A
  • ES2015
  • Internet Marketing
  • Javascript
  • Job Interviews
  • Job Search
  • Karma
  • Laravel
  • Linux
  • Linux/Unix Tips
  • MacOS
  • Microsoft Access
  • Microsoft Excel
  • Microsoft Outlook
  • Microsoft Word
  • News
  • Node
  • Open Source
  • PHP
  • Protractor
  • Resume Writing
  • Spring Boot
  • SQL
  • Ubuntu
  • VBA
  • VBScript
  • VirtualBox
  • Web Development
  • Windows Tips
  • Wordpress

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Copyright © 2023 · Magazine Pro on Genesis Framework · WordPress · Log in