473,748 Members | 2,471 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 1329

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

Similar topics

5
13573
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
3180
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
1072
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
3887
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
3041
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
13532
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
6245
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
984
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
2029
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
8984
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...
0
8823
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9363
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9312
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
8237
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...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
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
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.