473,698 Members | 2,616 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Quiting Word.Applicatio n

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.Applicatio n 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.FileSear ch fs;
Word.Applicatio n w;
w = new Word.Applicatio n();
fs = w.FileSearch;

fs.NewSearch();

{do search - this part works}

System.Runtime. InteropServices .Marshal.Releas eComObject(fs);
fs = null;
object saveChanges = false;
object missing = System.Reflecti on.Missing.Valu e;
w.Quit(ref saveChanges,ref missing,ref missing);
System.Runtime. InteropServices .Marshal.Releas eComObject(w);
w = null;

If I comment out all parts having to do with FileSearch (ie just create
Word.Applicatio n 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 1325

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
13570
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 = CreateObject("Word.Application")
8
3176
by: sudha | last post by:
Hi, To open a word doc from c#, i use the following code : Word.ApplicationClass WordApp = new Word.ApplicationClass (); // give any file name of your choice. object fileName = "C:\\test.doc"; object readOnly = false;
0
1069
by: Bill | last post by:
Hi all, I have developed a component to wrap MS-Word, and I use this to manage my reports. It´s a simple components, but it´s very useful...to eliminate this very tiresome declarations like this: Object flag = Type.Missing; bla, bla, and things like this...
7
3886
by: Zeke | last post by:
I'm using the following code to create word document but the problem is if you go to task manager you'll see a WINWORD.EXE process is running but not the application, here is the code: Word.Document aDoc= WordApp.Documents.Add(ref fileName, ref newTemplate, ref docType, ref isVisible); WordApp.Visible = true; aDoc.Activate(); WordApp.Selection.TypeText("Hello");
1
3036
by: Bernd Muent | last post by:
Hi together, I am using the following code in Visual Basic to open Word or Excel applications: Word: Dim w As Word.Application w = CType(CreateObject("Word.application"), Word.Application) w.Application.Documents.Open("test.doc") With w.Application.Selection
2
13529
by: Mikey | last post by:
Sample VB .NET source code to create mailing labels or customized letters using MS Word MailMerge This VB .NET source code will start MS Word and call methods and set properties in MS Word to execute a MailMerge to create mailing labels or customized letters. A label name known to MS Word MailMerge mailing label wizard may be used or a template file containing the field names Line1 thru Line5 for each record to be printed. If a...
7
6242
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 user and populated (with info from an Access database) at run-time, then saved as Word documents. The program I have coded works fine -- it does what I need it to do. But it has two problems: (1) it runs very slowly, and (2) it does not seem to...
1
977
by: Mitch Wardrop | last post by:
ok here it goes I must be doing something way off but it makes sense to me just not to VB.NET which would be a huge problem. Anyways I'll explain what I am doing than give code examples. basicly I've declared a thread in a module file where all my variables are declared for the enitre application, than it calls the thread from the main form and runs a sub routine located in a different class (I call it "work" class, this is where all the...
3
2026
by: Barry Edmund Wright | last post by:
Hi All, MS Access 2003 - using a split database. I am using a switchboard. I have set in Options to "Compact on Close". What code do I put behind the Exit button on the switchboard so the database Compacts the FE on Close and closed the MS Access Window? If I just use "Application.Quit acQuitSaveAll" it does not compact the database.
0
8683
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7740
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.