How to Capture Appt_Write Event in VBA when Appointment Object is Clicked and Dragged at the Same Time

风格不统一 提交于 2019-12-11 01:30:12

问题


I am trying to capture the appt_Write event on calendar appointment objects. The code below works well for every case EXCEPT when a user selects the appointment and drags it in one click.

Is there a better way to set the appt object so that I can capture the appt_Write event for any appointment on any calendar?

Private WithEvents objExplorer As Outlook.Explorer
Private WithEvents appt As Outlook.AppointmentItem

Public Sub Application_Startup()
Set objExplorer = Application.ActiveExplorer
End Sub

Private Sub objExplorer_SelectionChange()
 If objExplorer.CurrentFolder.DefaultItemType = olAppointmentItem Then
    If objExplorer.Selection.Count > 0 Then
      Set appt = objExplorer.Selection(1)
    End If
  End If
End Sub


Private Sub appt_Write(Cancel As Boolean)
'Do something with Appt Object here.  When a user clicks and drags,
'this write event has already fired by the time the Appt object is set.
End If
End Sub

回答1:


You can try to use Items.ItemChange event on the folder, but it only fires after the item is changed.



来源:https://stackoverflow.com/questions/14172866/how-to-capture-appt-write-event-in-vba-when-appointment-object-is-clicked-and-dr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!