How to disconnect Application.COMAddIns.Item().Object?

Status
Not open for further replies.
K

Kukulkan

Hello,

To access functions of my AddIn from external, I followed KB Article

http://support.microsoft.com/kb/240768 and set a reference at

start:

Application.COMAddIns.Item("MyAddInName.Connect").Object =

ConnectClass

It works great now, but after this, outlook does not close anymore

(stays in taskmanager).

I try'd to disconnect this relationship using the following methods in

my Explorer.Close event:

Application.COMAddIns.Item("MyAddInName.Connect").Object = Nothing

Set Application.COMAddIns.Item("MyAddInName.Connect").Object = Nothing

It does not work. Every time I get an error like 80004005 "method

'object' for object 'ComAddIn' failed".

The following does not help, too:

Application.COMAddIns.Item("MyAddInName.Connect").Connect = False

No effect at all :-(

How to release this connection to my class to allow outlook closing?

Kukulkan
 
K

Ken Slovak - [MVP - Outlook]

Is this VB.NET or VB6? You don't use Set in VB.NET. You also can't

disconnect an addin from within the addin's code, as Connect = False would

try to do.

Normally you never set that to Nothing, it's not necessary and will fire an

exception. What I usually do is to declare an Office.COMAddIn object at

class level in my Connect class and in the OnConnection() event I assign

that from the addInInst object passed in OnConnection(), then I set that

object's Object property to Me.

So in VB.NET it would be something like this:

' class level

Private addinInstance As Office.COMAddIn

' in OnConnection

addinInstance = TryCast(addInInst, Office.COMAddIn)

addinInstance.Object = Me

I don't release that in my teardown code, which is fired when the last

Explorer closes, there's an initialization error, OnDisconnect() or

OnBeginShutDown() fire.

If Outlook isn't exiting there's more likely to be various other Outlook or

Office objects not being released.

"Kukulkan" <dummy@inspirant.de> wrote in message

news:123e83b8-ff2a-40c4-b7b9-a783cffc9495@37g2000yqm.googlegroups.com...
> Hello,

> To access functions of my AddIn from external, I followed KB Article
> http://support.microsoft.com/kb/240768 and set a reference at
> start:

> Application.COMAddIns.Item("MyAddInName.Connect").Object =
> ConnectClass

> It works great now, but after this, outlook does not close anymore
> (stays in taskmanager).

> I try'd to disconnect this relationship using the following methods in
> my Explorer.Close event:

> Application.COMAddIns.Item("MyAddInName.Connect").Object = Nothing
> Set Application.COMAddIns.Item("MyAddInName.Connect").Object = Nothing

> It does not work. Every time I get an error like 80004005 "method
> 'object' for object 'ComAddIn' failed".

> The following does not help, too:
> Application.COMAddIns.Item("MyAddInName.Connect").Connect = False

> No effect at all :-(

> How to release this connection to my class to allow outlook closing?

> Kukulkan
 
K

Kukulkan

Oh, sorry.


> It is VB6! And if I uncomment the following line in my connection
> routine, the AddIn and Outlook closes fine:

> Application.COMAddIns.Item("MyAddInName.Connect").Object =
> ConnectClass


I mean if I *comment* this line (this line causes Outlook not to

close).

Kukulkan
 
K

Ken Slovak - [MVP - Outlook]

If this is VB6 code then you aren't really following that KB article you

cited, although I think that article isn't very well written to begin with.

In the OnConnection() event handler all you need is a line like this to make

the hook-up for external usage:

AddInInst.Object = Me

You don't need anything else there at all.

"Kukulkan" <regify@googlemail.com> wrote in message

news:02d33ade-6e0d-46da-a2d0-9c7697a6f64b@31g2000vbf.googlegroups.com...
> Oh, sorry.
>
> > It is VB6! And if I uncomment the following line in my connection
> > routine, the AddIn and Outlook closes fine:
>

>> Application.COMAddIns.Item("MyAddInName.Connect").Object =
> > ConnectClass


> I mean if I *comment* this line (this line causes Outlook not to
> close).

> Kukulkan
 
K

Kukulkan

Hi Ken,


> In the OnConnection() event handler all you need is a line like this to make
> the hook-up for external usage:

>     AddInInst.Object = Me

> You don't need anything else there at all.


Thank you very much. :)

This guided me to the right way and now it works. I needed to wrap the

function from the connector to my ConnectClass but it works ok here.

Kukulkan
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
bmtjedi Set objApp = Application Not Working in O365-32bit Using Outlook 1
avant-guvnor Outlook.Application now produces error Outlook VBA and Custom Forms 5
C Custom Application Form send Email to Another User Using Outlook 1
N Select Existing BCM Business Contact in C# application Using Outlook 0
S Using "start application" rule action Using Outlook 2
smokiibear windows security mail application not accepting username and password Using Outlook 0
Y VBA - Application Filedialog Hidden Behind Outlook Using Outlook 0
T Synchronize outlook appointments through web application. Using Outlook 1
O Outlook 2010 Stops Working When Accounting Application Tries To Send eMail Using Outlook 4
C MAPI to access a 64 bit Outlook from a 32 bit application; or access via ODBC Using Outlook 0
K Handling application.quit event Outlook VBA and Custom Forms 8
A turn Outlook into a Drag-and-drop application Outlook Wishlist 2
M VSTO C#: How do I declare an application scope variable? Outlook VBA and Custom Forms 2
E Turn application visibility off Outlook VBA and Custom Forms 2
T Run application from cmd button Outlook VBA and Custom Forms 5
D Outlook 2007 Will Not Send Mail From C# Application Outlook VBA and Custom Forms 7
P Supporting threads in Outlook VBA application Outlook VBA and Custom Forms 1
R vba instantiated internetExplorer.application differs from user la Outlook VBA and Custom Forms 1
D outlook.exe application error - breakpoint has been reached. fix? BCM (Business Contact Manager) 1
P Drag and Drop mails from Outlook to Clarion6 Application Outlook VBA and Custom Forms 5
J Office application does not match advisory. Why? BCM (Business Contact Manager) 3
D Application.ActiveInspector() is Null on Ribbon Load Outlook VBA and Custom Forms 1
D Application.ActiveInspector().CurrentItem Returns Wrong(Old) Value Outlook VBA and Custom Forms 3
L RE: BCM Office Application Issue BCM (Business Contact Manager) 1
R Can calendar be displayed in another Office application? Outlook VBA and Custom Forms 1

Similar threads

Top