469,601 Members | 2,039 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,601 developers. It's quick & easy.

Quiting Word.Application

I'm trying to use Office's FileSearch object to search for files.
I'm using Visual Studio 2002 c# and Word 2000.

The problem I am having is realeasing the Word.Application object.
When I try to use the Quit() method I get an error:

"Microsoft Word for Windows has encountered a problem and needs to
close. We are sorry for the inconvenience"

Either way I end up with multiple WinWord processes running.

Here is part of my code:

Office.FileSearch fs;
Word.Application w;
w = new Word.Application();
fs = w.FileSearch;


{do search - this part works}

System.Runtime.InteropServices.Marshal.ReleaseComO bject(fs);
fs = null;
object saveChanges = false;
object missing = System.Reflection.Missing.Value;
w.Quit(ref saveChanges,ref missing,ref missing);
System.Runtime.InteropServices.Marshal.ReleaseComO bject(w);
w = null;

If I comment out all parts having to do with FileSearch (ie just create
Word.Application and then use Quit() )
it works and WinWord is terminated.

I think I need to get rid of the FileSearch object first, before using
Quit() but I am not sure how to do this.

jorge de cardenas

Aug 18 '06 #1
0 1164

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by sudha | last post: by
1 post views Thread by Bernd Muent | last post: by
1 post views Thread by Mitch Wardrop | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.