?
Solved

Event Handler Problem

Posted on 2006-05-15
5
Medium Priority
?
285 Views
Last Modified: 2013-11-12
The code snippet below works fine when Microsoft Outlook is NOT running.
IE: MS Word opens the .doc file OK and the close event fires OK when MS Word is closed.

However when MS Outlook (email client) is running in the background, NO events are fired when MS Word is closed.

(I have Microsoft Office 2003 installed)

Does anybody have any ideas as to what is causing the code to fail?
--------------------------------------------------------------
.
.
process = new Process();
ProcessStartInfo processStartInfo= new ProcessStartInfo("C:\temp.doc");
processStartInfo.Verb = "Open";
processStartInfo.CreateNoWindow = false;
process.StartInfo = processStartInfo;
process.Start();

process.Exited += new System.EventHandler(process_Exited);
process.EnableRaisingEvents = true;  // Events fire when MS Word closes
.
.

private void process_Exited(object sender, System.EventArgs e)
{
 // do something
}
0
Comment
Question by:javapossum
  • 2
  • 2
5 Comments
 
LVL 1

Expert Comment

by:chuang4630
ID: 16690425
This question is more appropriate to be posted in the App/MS Office area, in my opinion.

The code itself looks fine to me. The issue seems to be Office 2003 specific.
0
 

Author Comment

by:javapossum
ID: 16694143
To chuang4630" How do I transfer this question to the area you suggested?
0
 
LVL 3

Expert Comment

by:Mikeh926
ID: 16752414
Hi,
Do you have "Use Microsoft Word to edit e-mail settings" selected in your Outlook options?

If you do then Outlook runs a copy of WinWord in the background. Look in task manager and see if winword.exe is listed when you have outlook running. This process will remain running whilst Outlook is running regardless of how many word docs you open or close. Although you have multiple documents open, there is only even one instance of winword.exe and until you close everything that is using winword (including Outlook), it's process won't terminate.

So, to answer youe question, you don't get an event because the winword.exe process has not existed because it's in use by Outlook.

Regards,
Mike.
0
 
LVL 3

Accepted Solution

by:
Mikeh926 earned 600 total points
ID: 16759499
Sorry, I was having a figure trouble in my last paragraph... it should read:

So, to answer your question, you don't get an event because the winword.exe process has not exited because it's in use by Outlook.
0
 

Author Comment

by:javapossum
ID: 16773967
Thanks very much for your answer Mike, this is exactly what is causing it :-)
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Pretext and Context: In this series, I wish to design the data model of systems in question. I will start by defining the scope and boundaries of the system, followed by subsystems involved, then finally the entities in those systems and subsystems…
Introduction This question got me thinking... (http://www.experts-exchange.com/questions/28707487/GLOBALS.html) Why shouldn't we use Globals? This is a simple question without a simple answer.  How do you explain these concepts to a programmer w…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month16 days, left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question