OnError Event
Occurs when Microsoft Outlook encounters an error while synchronizing a user’s folders using the specified synchronization profile. This event is not available in VBScript.
Sub object_OnError(ByVal Code As Long, ByVal Description As String)
object An expression that evaluates to a SyncObject object.
Code A unique value that identifies the error.
Description Required. A textual description of the error.
Example
This example displays a message box describing the synchronization error and sets attributes of controls on a form. The sample code must be placed in a class module, and the Initialize_handler
routine must be called before the event procedure can be called by Microsoft Outlook.
Dim myOlApp As New Outlook.Application
Dim WithEvents mySync As Outlook.SyncObject
Dim myForm As New Form1
Sub Initialize_handler()
Set mySync = myOlApp.Session.SyncObjects.Item(1)
End Sub
Private Sub mySync_OnError(ByVal Code As Long, ByVal Description As String)
Form1.Label1.Caption = "Synchronization failed."
mySync.Stop
Form1.Command1.Enabled = False
Form1.Command2.Enabled = False
MsgBox "Unexpected sync error" & Str(Code) & ": " & Description
End Sub