Outlook 2007 - catch an event when user creates a new appointment

Posted on 2011-10-10
Last Modified: 2012-05-12
I got irritated with the warning dialog that says "no location has been specified" whenever I send a meeting invite in Outlook 2007 with blank location.  There seems to be no way to turn this warning off, so I thought maybe if I write VBA to automatically set the location to " " (single space) whenever I create a new appointment, that would be a reasonable work around.

I tried the following code.  However, it only seems to be triggered when the user saves changes to the new appointment.  I want to catch an event when the new appointment dialog first appears, e.g. when the user first double clicks in the Calendar to create a new appointment.

Of course, any suggestions for alternative approaches to solving the original problem are very welcome too!

Private WithEvents olkCalendar As Items

Private Sub Application_Quit()
    Set olkCalendar = Nothing
End Sub

Private Sub Application_Startup()
    Set olkCalendar = Session.GetDefaultFolder(olFolderCalendar).Items
End Sub

Private Sub olkCalendar_ItemAdd(ByVal Item As Object)
    If Item.Location = "" Then
      Item.Location = " "
    End If
End Sub

Open in new window

Question by:jan24
    LVL 76

    Accepted Solution

    Hi, jan24.

    There aren't any events triggered triggered specifically by opening an appointment.  However there is an event triggered when an item, any type of item, is opened.  That event is the NewInspector event.  If you trap that event, then you can can test to see if the item open in the inspector window is an appointment.  If it is, then you can check to see if the location field is blank and fill it in if it is.  Something like this.
    Private WithEvents olkInspectors As Outlook.Inspectors
    Private Sub Application_Startup()
        Set olkInspectors = Application.Inspectors
    End Sub
    Private Sub Application_Quit()
        Set olkInspectors = Nothing
    End Sub
    Private Sub olkInspectors_NewInspector(ByVal Inspector As Inspector)
        Dim olkAppt As Outlook.AppointmentItem
        If Inspector.CurrentItem.Class = 26 Then
            Set olkAppt = Inspector.CurrentItem
            If olkAppt.Location = "" Then
                olkAppt.Location = "Some Value"
            End If
        End If
    End Sub

    Open in new window

    LVL 2

    Author Comment

    That worked perfectly, BlueDevilFan.  Many thanks for your help!
    LVL 76

    Expert Comment

    by:David Lee
    You're welcome!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Find out how to use dynamic social media in email signatures with this top 10 DOs & DON’Ts.
    This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now