By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,460 Members | 1,508 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,460 IT Pros & Developers. It's quick & easy.

Word process not terminating

P: n/a
I'm automating word form a c# windows application for spell checking
purposes. The problem is that sometimes the winword.exe process does
not terminate. Any clues why? I posted some code below.
/Martin
ArrayList arrPositions = new ArrayList();
ArrayList arrLengths = new ArrayList();
ArrayList[] arrList = new ArrayList[2];
int intPosition = 0;

Word.ApplicationClass objWord = null;
object junk = System.Reflection.Missing.Value;
try {
objWord = new Word.ApplicationClass();
string[] strArray = str.Trim().Split(new char[] {' '});
for(int i = 0; i < strArray.Length; i++) {
string strWord = strArray[i];
if(!objWord.CheckSpelling(strWord, ref junk, ref junk, ref junk,
ref junk, ref junk, ref junk, ref junk, ref junk, ref junk, ref junk,
ref junk, ref junk)) {
arrPositions.Add(intPosition);
arrLengths.Add(strWord.Length);
}

int n = strWord.Length + 1;
intPosition += n;
}
arrList[0] = arrPositions;
arrList[1] = arrLengths;
return arrList;
}
catch (Exception ex) {
throw ex;
}
finally {
if(objWord != null) {
objWord.Quit(ref junk, ref junk, ref junk);
objWord = null;
}
}
Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Martin,

You need to call Marshal.ReleaseCOMObject

Check out the following article:

317109 PRB: Office Application Does Not Quit After Automation from Visual
http://support.microsoft.com/?id=317109
Hope this helps!
Bharat Patel
Microsoft, Visual Basic .NET

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only. Thanks.

Nov 15 '05 #2

P: n/a
Thanks Bharat!

That helped a lot. It seems if I call my "spell check" method several
times, within a short time interval, the winword.exe remains after
trying to shut it down (I call GC.Collect() as the article suggested).
The problem is that I cannot see a pattern, it seems random. The
process shuts down more often than before, so it is improving!

/Martin
Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.