1

I set up a web calendar in office 365 which is connected with "Data Sourse" with Access 2016. Also at the same time the local Outlook is "looking" on the web folder of calendar (outlook at office 365). All three Access (i.e. linked table)-web calendar-local calendar synchronize correctly when adding, changing or removing an appointment.

I would like to "trap" all of the above events and use in my database. for that reason I added module with ModOutlookRespond with code:

Public Sub Initialize_handler()
    Set m_olapp = GetObject(, "Outlook.Application")
    m_olapp.GetNamespace("MAPI").Logon "Microsoft Outlook"
    Set m_olNameSpace = m_olapp.GetNamespace("MAPI")
    'this allows us to capture an appoitment item change event
    Set m_olAppoitmentItems = m_olNameSpace.GetDefaultFolder(olFolderCalendar).Items
    Debug.Print "Connection Initialised"
End Sub

and added Initialize_handler() on the Open event of Main form.

On the Main form I added also the code:

Public WithEvents m_olapp As Outlook.Application
Public WithEvents m_olAppoitments As Outlook.Items
Public m_olNameSpace As Outlook.NameSpace

Private Sub m_olAppoitments_ItemAdd(ByVal Item As Object)
    Debug.Print "Item has added" & Item.Subject
End Sub

I am getting so far only the Debug.Print "Connection Initialised" but not a single time any message from Add event (or any other I tried). Any ideas what I can try?

Mathieu Guindon
  • 69,817
  • 8
  • 107
  • 235
  • If you stick `Option Explicit` at the top of `ModOutlookRespond`, I bet your code stops compiling and complains about `m_olapp` not being declared anywhere. – Mathieu Guindon Nov 16 '17 at 20:30
  • Gah, just realized your form is an Access form, not a UserForm - still, the same OOP principles apply; you've defined instance fields on a *type*, but you don't have an *instance* of that *type* to actually do the work. – Mathieu Guindon Nov 16 '17 at 20:50

0 Answers0