Create a meeting or appointment Outlook Visual Basic for Application code

Create a meeting or appointment Outlook Visual Basic for Application code

Appointment

Object exposes various properties and methods by which we can create a business appointment using VBA code. In this article, we will take inputs from excel sheet and create meeting invite or appointment.

Code example

Sub createAppointment()
    'Outlook application object declaration
    Dim oApp As Outlook.Application
    
    'bind current outlook instance
    Set oApp = GetObject("", "Outlook.Application")
    
    
    'Declare object
    Dim oAppointment As AppointmentItem
    
    'Create new item
    Set oAppointment = oApp.CreateItem(olAppointmentItem)
    
    'Assign proerties
    oAppointment.Subject = Range("B1")
    oAppointment.Location = Range("B2")
    oAppointment.Categories = Range("B3")
    oAppointment.Recipients.Add Range("B4")
    oAppointment.Body = Range("B5")
    oAppointment.Start = Range("B6")
    oAppointment.End = Range("D6")
    
    'Display
    oAppointment.Display
    
    'Send
    oAppointment.Send
    
    'Close outlook
    oApp.Quit
    'CleanUp
    If Not oAppointment Is Nothing Then
        Set oAppointment = Nothing
    End If
    
    If Not oApp Is Nothing Then
        Set oApp = Nothing
    End If
End Sub

Input

Output

Next >> Create contact item in outlook using VBA code

Leave a Reply

Your email address will not be published.