Outlook sharing Word Addins

E

Enn

I have written a C# application which uses Word 2003 Application and
Documents via Interop. I display a Word document in the user control which in
turn is in the Windows Form. All works fine until I open the Outlook when my
program is running. Once when Outlook gets opened, I heard it shares the
Addins of the Word 2003. When I close my application the Winword.exe is still
available in the task manager. When Outlook is closed it will not terminate
this Winword.exe instance either making it a orphan. I need to kill it
manually from the task manager.

My questions:

1. How do I prevent Outlook from using the word addins whether it is opened
after my program starts executing or before?

2. Is there any way by which I can prevent Outlook sharing the addins from
MY instance of Word?

Thanks in advance
 
K

Ken Slovak - [MVP - Outlook]

You would need an Outlook addin to control Outlook behavior.

If you check for Window.EnvelopeVisible = True you will know when the active
window is showing an email item (True) or not (False). You can control
whether or not your code runs in that context.
 
E

Enn

I am handling WindowActivate event in "my" application and check for the
EnvelopeVisible. I get this event only if I open an eMail editor from Outlook
else I do not.

But the issue here is when I run my application without Outlook open, I see
a Winword.exe instance in the task manager. If I close my application it goes
away. But if I open the Outlook when my application is running, it shares the
WinWord. I close my application and Outlook next. The Outlook does not bother
to close the WinWord instance.
 
K

Ken Slovak - [MVP - Outlook]

That's expected behavior. When WordMail is enabled an instance of Word is
opened when Outlook is opened and kept open until Outlook is logged off.

You can track the count of open windows in Word and if it's 0 you can force
Word to shut down: oWord.Quit, or you can just live with the situation.
 
E

Enn

This effectively means that:

1. My client can never / forced not to - open Outlook "after" my application
is loaded. If the client opens Outlook after the application is opened and
closes application first, Outlook next - the Winword.exe will alway remain in
memory forcing the Word to display the "Document recovery" next time when the
Word is opened. This happens even if there are no addins available.

2. Quit works only with the documents which my application opens. I do it
like this - if I open more documents, the WordAppliation.Documents.Count gets
incremented. If I close a document the count decreases. When the Count goes
to 0, I Quit the WordApplication by calling Quit, BUT this does not free the
instance shared if the Outlook was opened after my application is opened.
 
K

Ken Slovak - [MVP - Outlook]

No matter what order things are opened in you should not get a
OnDisconnection event until Word is closing. If that's after your
application is being closed or after Outlook is being closed shouldn't
matter. When you get that event you release all your objects and Word should
close normally.
 

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