Outlook 2003 will not terminate

  • Thread starter Thread starter Michael Bredbury
  • Start date Start date
M

Michael Bredbury

I am automating Outlook 2003 version 11.5608.5606 using Visual Basic 6
(SP3) on a Windows XP Pro (SP1) PC. The problem I am having is that
Outlook 2003 will not terminate if I synchronise. I am using the
following code as a test-rig:

Option Explicit
Private Sub Command1_Click()

Dim objOutlook As Outlook.Application
Dim objNameSpace As Outlook.NameSpace

Set objOutlook = New Outlook.Application
Set objNameSpace = objOutlook.GetNamespace("MAPI")

'The next line will prevent Outlook from terminating (try
commenting it out)
objNameSpace.SyncObjects.Item(1).Start

MsgBox "Waiting for the Sync to complete..."

Set objNameSpace = Nothing
objOutlook.Quit

Set objOutlook = Nothing 'Outlook should terminate after this
line!

End Sub

I have tried different code variations inc. using .Stop already.
Should I be doing something else after the line:
'objNameSpace.SyncObjects.Item(1).Start' ?
(My real code traps the SyncEnd, SyncStart, Progress and OnError
events so that it is known when Outlook has finished the Sync).

A manual Sync using Outlook (not automated) works fine.

Cheers

Mike Bredbury
 
If you start a synch that is an Outlook thread and Outlook won't
terminate until that thread terminates. Either wait for the synch to
be finished before closing Outlook or don't start a synch.
 
Ken Slovak - said:
If you start a synch that is an Outlook thread and Outlook won't
terminate until that thread terminates. Either wait for the synch to
be finished before closing Outlook or don't start a synch.

Thanks for that Ken. However, I am still convinced this is a bug in
Outlook 2003 unless you or someone else can show me simple sample code
that does synch. and close Outlook 2003 correctly!

Cheers

Michael Bredbury.
 
Now Fixed!!

I have discovered why Outlook would not terminate properly. It was due
to some interaction with a GroupWise email client that was previously
on the computer I was using. When I ran the GroupWise Cleaning Agent
program (setupca.exe) which totally removes any trace of GroupWise
from the computer, all is well with the sample code in my original
post, and now Outlook 2003 terminates properly.

Hope this helps someone else!

Michael Bredbury.
 
Back
Top