Consulting

Results 1 to 4 of 4

Thread: Outlook VBA validate appointment

  1. #1

    Outlook VBA validate appointment

    Can I use VBA to validate an appointment and check if the status is set to busy when the user clicks save? If the time is set to free it should pop up a warning.

  2. #2
    VBAX Expert JP2112's Avatar
    Joined
    Oct 2008
    Location
    Astoria, NY
    Posts
    590
    Location
    Can you maybe provide a specific example?

    Do you want to check someone else's free/busy time?

    --JP

    Quote Originally Posted by cornall
    Can I use VBA to validate an appointment and check if the status is set to busy when the user clicks save? If the time is set to free it should pop up a warning.

  3. #3
    To be more specific,

    We have various calendars in outlook representing company resources e.g. laptops.

    Our users book time against these resources by setting up appointments/meetings and adding the resource as a required attendee.

    A "feature" of Outlook is that when you set an appointment to be an all day event the free busy time reverts to Free. This means other users can double book the resource. It happens often as users dont check the calendar of the resource they just add the resource as an attendee.

    As I couldn't find a way to do it using VBA I have written a C# application which checks the shared calendars every x hours and e-mails the orginizer if the resource has been booked as free.

    I was wondering if there was a way to aleart the user to the fact that the free/busy time has reverted to free at runtime using VBA?

    Cheers D

  4. #4
    VBAX Expert JP2112's Avatar
    Joined
    Oct 2008
    Location
    Astoria, NY
    Posts
    590
    Location
    You can set up some event code in VBA that checks every new appointment to see if it is an All Day Event. If so, it sets the olBusyStatus to olBusy. But you can't set the resource to "busy" that way --you have to schedule it as a resource, not an attendee, because nobody is on the other end to "accept" the appointment.

    When you create a new meeting request (I press Ctrl-Shift-Q in Outlook 2003), click the "To" button, scroll to the resource you want to use (conference room, projector, etc) and click the "Resources" button at the bottom of the dialog box.

    Now, if the resource is already booked during that time, you should get a message to that effect.

    Here's the sample code for the end user to check if an appointment they are adding is an All Day Event marked "Free."

    Private WithEvents MyItems As Outlook.Items
    Private Sub Application_Startup()
     Dim objNS As Outlook.NameSpace
     Set objNS = GetNamespace("MAPI")
     Set MyItems = objNS.GetDefaultFolder(olFolderCalendar).Items
    End Sub
    Private Sub MyItems_ItemAdd(ByVal item As Object)
    Dim Appt As Outlook.AppointmentItem
    If TypeOf item Is Outlook.AppointmentItem Then
      Set Appt = item
      With Appt
        If .AllDayEvent Then
          .BusyStatus = olBusy
          .Save
        End If
      End With
    End If
    End Sub


    Quote Originally Posted by cornall
    To be more specific,

    We have various calendars in outlook representing company resources e.g. laptops.

    Our users book time against these resources by setting up appointments/meetings and adding the resource as a required attendee.

    A "feature" of Outlook is that when you set an appointment to be an all day event the free busy time reverts to Free. This means other users can double book the resource. It happens often as users dont check the calendar of the resource they just add the resource as an attendee.

    As I couldn't find a way to do it using VBA I have written a C# application which checks the shared calendars every x hours and e-mails the orginizer if the resource has been booked as free.

    I was wondering if there was a way to aleart the user to the fact that the free/busy time has reverted to free at runtime using VBA?

    Cheers D

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •