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;
}
}