473,396 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Word process not terminating

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
2 1731
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: The Roys | last post by:
Hi Im doing something wrong in quitting the Word.Application in my VB program. I have General Declarations Dim AppWord As Word.Application Form_Load() Set AppWord =...
1
by: Earl Eiland | last post by:
I'm running a PyWin program that executes another program using subprocess.Popen(). Unfortunately, this other program isn't well behaved, and frequently terminates without terminating its process....
0
by: Henrik | last post by:
Hi, I would like to take a process object and turn it into an instance of a com-object somehow. I know that I can get all Microsoft Word processes running by using...
0
by: David Akerman | last post by:
Hi, Background ======== I've written a Web App in C# which controls a pool of Word Applications for mailmerge purposes (not ideal using Word non-interactively I know, but I have explored...
0
by: gizmo | last post by:
We have a requirement to initiate more than one instance of an application using the filenames. (the example below will start two instances of MS Word). The problem is that we need to close each...
7
by: Dave | last post by:
Apologies for the newbie question. I have created a vb.net program for my company that is designed to work with Word Templates (about forty of them that we commonly use) that are selected by the...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
209
by: arnuld | last post by:
I searched the c.l.c archives provided by Google as Google Groups with "word input" as the key words and did not come up with anything good. C++ has std::string for taking a word as input from...
9
by: George | last post by:
C with 2 sprained hands. I would nlike to emulate the t4 encoding scheme using the following graphic: * * * * * * ***** o O o o
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.