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

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 = " "
      Item.Save
    End If
End Sub

Open in new window

LVL 2
jan24Asked:
Who is Participating?
 
David LeeCommented:
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

0
 
jan24Author Commented:
That worked perfectly, BlueDevilFan.  Many thanks for your help!
0
 
David LeeCommented:
You're welcome!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.