Wednesday, 15 June 2016

Programatically create an Outlook appointment

I am constantly creating 'Intercall' meetings so I:

  1. Create an appointment as a .oft file.
    This will be the template for these new appointments.
  2. Add the code at the end of this article to the VBA Project.
  3. Add a button to call the 'Intercall' procedure.
    e.g. As a Quick Access Toolbar button



' The template is saved as %APPDATA%\Microsoft\Templates\Intercall.oft
Public Sub Intercall()
  ' This is the template appointment that was saved previously
  Dim path$
  path = Environ("APPDATA") & "\Microsoft\Templates\Intercall.oft"
  
  Dim Appt As Outlook.AppointmentItem
  Set Appt = Application.CreateItemFromTemplate(path$)
  ' Get the next 1/2h slot
  Appt.start = CDate(Int(CDbl(Now) * 48 + 1) / 48)
  Appt.End = DateAdd("n", 30, Appt.start)
  Appt.Display
End Sub
Post a Comment