Progress Event Example

This example updates a label on a form to show the progress of synchronization. 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_Progress(ByVal State As Outlook.OlSyncState, ByVal Description As String, ByVal Value As Long, ByVal Max As Long)
    If State = olSyncStarted then 
        Cap = "Synchronization started: "
    Else
        Cap = "Synchronization stopped: "
    End If
    Cap = Cap & Str(State / Max * 100) & "% " & Description
    Form1.Label1.Caption = Cap
End Sub