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
' 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