Make Winword Go Away :-(

MarkNewVBGuy
07-11-2001, 09:29 AM
My very first VB 6.0 project (have a little VBA and C++ experience). I use the following code to open Word from VB:
' create document in Word by [OLE] Automation.
' create a word doc and save it with a new name.
objWordDoc = CreateObject("Word.Application")
objWordDoc.Visible = False
objWordDoc.Documents.Add

I add lines to the doc in the program; everything seems to work OK. I run the code then look at the Word doc via Word (opened from my Ofc97 toolbar). The doc is there and the lines I’ve added are in it.

My problem is: while testing repeatedly, eventually I run out of space on my PC for basic stuff like printing, opening programs, etc. When I look at the Close list (I get when I do a Ctrl-Alt, Delete) I see many-many copies of Winword active and have to close each one of them separately or restart my system to free things up.

My question is: how do I close the Winword activity from within my VB program? My word object is called: objWordDoc. I’ve tried objWordDoc.close, objWordDoc.delete, delete objWordDoc in the code, none of which do what I want. I do do an ActiveDocument.Save and .Close at the end for the document itself, but apparently that’s not enough.

It’s obvious I’m a novice (but I’m having lots of fun w/VB :) ). What am I missing? Thanks, Mark

KesleyK
07-11-2001, 10:02 AM
Try:

objWordDoc.Application.Quit

______
Cheers!

Neptune
07-11-2001, 10:48 AM
Yes do what KesleyK suggested, later release your object.
Set objWordDoc = Nothing

You need to close every fýle you opened and release all objects you set in VB after you have done wýth them.

MarkNewVBGuy
07-11-2001, 12:09 PM
Thanks! Worked like a charm :-)

MarkNewVBGuy
07-11-2001, 12:11 PM
thanks for the advise!

Mark

KesleyK
07-11-2001, 01:24 PM
np

______
Cheers!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum