A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

SyncEnd and other Sync Event not firing



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 8th 08, 08:23 AM posted to microsoft.public.outlook.program_vba
Alban
external usenet poster
 
Posts: 7
Default SyncEnd and other Sync Event not firing

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
  #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

  #3  
Old August 11th 08, 10:40 PM posted to microsoft.public.outlook.program_vba
Alban
external usenet poster
 
Posts: 7
Default SyncEnd and other Sync Event not firing

Thanks for the reply. I think my first post was not very clear.
I am trying to create a console application that will do send/receive on an
Outlook account. I need the syncEnd event to control when to terminate the
application.

I think my problem comes from the overall installation of office and
programming it. Here is what I did:
I downloaded Microsoft visual studio express 2005 for visual basic and
created a console application. If I copy/paste the previous code, it does the
sync (provided I put a 2 sec timer to let the sync happen). If I launch
outlook prior to my console application, I can even see the tray icon
performing the send/receive.

My only problem is that I can not catch any event. I tried with item_send or
other events, all failed. So my question could be simpler:

What environment do I need to create a console application which can catch
office events. It is related to installing visual studio tools for office? Am
I confused between VBA and VB? Do I need to add more reference to the VB
project?

I you have clues to put me on track, it would be great!

Thanks in advance

Alban


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Click event not firing in Outlook 2007 EKH Outlook - Using Forms 2 June 27th 08 01:26 AM
appointment 'Write' event not firing as expected JohnV@nn Add-ins for Outlook 0 May 22nd 07 06:18 PM
appointment 'Write' event not firing as expected JohnV@nn Add-ins for Outlook 0 May 22nd 07 04:55 PM
Write event not firing in list view Rick H Add-ins for Outlook 2 February 21st 07 03:53 PM
MouseWheel event not firing aiKeith Outlook - Using Forms 1 February 9th 07 09:07 PM


All times are GMT +1. The time now is 04:39 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.