View Single Post
  #2  
Old August 11th 08, 09:41 PM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default SyncEnd and other Sync Event not firing


If you select the SyncEnd event in the object browser and click f1 you get a
code example. Just ensure that you call the initialize handler from the
Application_Startup event.

--
Best regards
Michael Bauer - MVP Outlook

: VBOffice Reporter for Data Analysis & Reporting
: Outlook Categories? Category Manager Is Your Tool
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Thu, 7 Aug 2008 23:23:01 -0700 schrieb Alban:

Hi,

I am following up on this old thread:

http://www.microsoft.com/communities...=en-us&m=1&p=1

I am desperatly unable to catch the sync end event. I am synching an

account
with exchange server and need to wait for the end of synch before ending

the
program.

Any clue why the following code is not firing the exception?
Thanks in advance for any help


Imports Outlook = Microsoft.Office.Interop.Outlook

Module Module1
Public Interface SyncObjectEvents
End Interface

Public bSendReceiveEnded As Boolean

Private WithEvents instance As Outlook.SyncObject

Sub instance_SyncEnd()
MsgBox("triggered")
bSendReceiveEnded = True
End Sub

Sub Main()
On Error Resume Next
' Create an Outlook application.
Dim oApp As Outlook._Application = New Outlook.Application
' Create the name space.
Dim oNS As Outlook._NameSpace = oApp.GetNamespace("mapi")
Dim oSyncs As Outlook.SyncObjects

bSendReceiveEnded = False
oSyncs = oNS.SyncObjects
instance = oSyncs.Item(3)

' Send and receive.
instance.Start()
Do While bSendReceiveEnded = False
System.Windows.Forms.Application.DoEvents()
Loop

oSyncs = Nothing
oNS = Nothing
oApp = Nothing
End Sub

End Module


I added to the project references to the .COM 'Microsoft Outlook 11.0

Object
Library' and to .NET system.windows.forms

I am compiling with VB 2005 express edition and using Outlook 2003

Ads