J
jorgedec
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;
fs.NewSearch();
{do search - this part works}
System.Runtime.InteropServices.Marshal.ReleaseComObject(fs);
fs = null;
object saveChanges = false;
object missing = System.Reflection.Missing.Value;
w.Quit(ref saveChanges,ref missing,ref missing);
System.Runtime.InteropServices.Marshal.ReleaseComObject(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
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;
fs.NewSearch();
{do search - this part works}
System.Runtime.InteropServices.Marshal.ReleaseComObject(fs);
fs = null;
object saveChanges = false;
object missing = System.Reflection.Missing.Value;
w.Quit(ref saveChanges,ref missing,ref missing);
System.Runtime.InteropServices.Marshal.ReleaseComObject(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