问题
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