Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Mar 2005
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Access querying Outlook (2003)

    Hullo,

    I hope everyone is having a great Easter.

    What I would like to be able to do is twofold.

    Firstly. See if a meeting is in Outlook from a supplied set of date/times from Access. eg. StartDateTime = #28/3/05 10:00:00#, EndDateTime = #28/3/05 10:30:00#
    Secondly. If there is a meeting at this time, then delete it within Access.

    Thank you

    Robin

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Access querying Outlook (2003)

    The following code is closely related to the code we discussed in your earlier thread about Outlook appointments:

    Sub DeleteAppointment(dtStart As Date, dtEnd As Date)
    Dim olApplication As Outlook.Application
    Dim olNsp As Outlook.NameSpace
    Dim strStart As String
    Dim strEnd As String
    Dim olAppts As Outlook.Items 'Outlook Appointments
    Dim curAppt As Outlook.AppointmentItem

    On Error GoTo ErrHandler

    Set olApplication = CreateObject("Outlook.Application")
    Set olNsp = olApplication.GetNamespace("MAPI")
    strStart = Format(dtStart, "dd/mm/yyyy hh:mm AM/PM")
    strEnd = Format(dtEnd, "dd/mm/yyyy hh:mm AMp/PM")

    Set olAppts = olNsp.GetDefaultFolder(olFolderCalendar).Items
    Set curAppt = olAppts.Find("<!t>[Start]<!/t> = """ & strStart & _
    """ And <!t>[End]<!/t> = """ & strEnd & """")
    If Not curAppt Is Nothing Then
    curAppt.Delete
    End If

    ExitHandler:
    Set olAppts = Nothing
    Set olNsp = Nothing
    Set olApplication = Nothing
    Exit Sub

    ErrHandler:
    MsgBox Err.Number & " " & Err.Description, vbExclamation
    Resume ExitHandler
    End Sub

    Call it like this:

    Call DeleteAppointment(#3/28/05 10:00#, #3/28/05 10:30#)

    (If you use literal dates in VBA code, they must be in US date format)

Posting Permissions

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