Incomplete Outlook Shutdown when Using COMAddIns Object

J

Jim

Hello,

I am experimenting with calling a subroutine defined in my Add-In from
a separate application. A minimal VB6 application containing the code
below correctly calls the ButtonSelected subroutine in my Outlook 2000
Add-In.

The problem is that once this separate application is running and I
close Outlook, Outlook remains in memory and the separate application
can still successfully call the ButtonSelected subroutine.

If I exit the separate application, then Outlook removes itself from
memory.

Obviously, Outlook thinks there is still some kind of outstanding
reference for the case where it does not close completely. But the
code below looks to me like it does not leave any dangling references.

I would like for Outlook to shut down completely, and not remain in
memory if my separate application is running but otherwise idle.

Any suggestions would be welcome.

Thanks.

Jim

Code from the separate VB6 application -- not an excerpt -- this is
all there is:

Private Sub cmdButton_Click()

On Error Resume Next

Dim objOutlook As Outlook.Application

Set objOutlook = GetObject(, "Outlook.Application")
If objOutlook Is Nothing Then
MsgBox "Outlook is Not Running"
Exit Sub
End If
Set objOutlook = Nothing

Dim objAddIn As Object

Set objAddIn = _
Application.COMAddIns.Item("MyAppl.MyApplAddInDesigner").Object
If objAddIn Is Nothing Then
MsgBox "MyAppl is Not Running"
Else
'Call sub defined in the Add-In.
objAddIn.ButtonSelected
End If
Set objAddIn = Nothing

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top