PDA

Click to See Complete Forum and Search --> : Word object


Tonatiuh
Dec 29th, 1999, 01:59 AM
I'm opening a Word object in two diferent ways but, the Instance of Word is still in memory all time later.

Method 1
Dim objWord As New Word.Application
objWord.Visible = False
objWord.Documents.Open "Document.doc"
objword.Printout
objWord.Documents.Close
Set objWord = Nothing


Method 2

Dim docWord as Object
Set docWord = CreateObject("Word.Basic")
docWord.FileOpen ("document.doc")
docWord.FilePrint
docWord.FileClose
Set docWord = Nothing


I'm using the Word 8 reference. In both cases the Word instance stay on memory. I think the 'Set DocWord = Nothing' is not the correct sentence to close the Word instance.

Any idea will be deeply apreciated.

Thanks!


[This message has been edited by Tonatiuh (edited 12-29-1999).]

badgers
Dec 29th, 1999, 05:00 AM
I have the same problem. I cant get the instance of word to go away.


------------------
I am so skeptacle, I can hardly believe it!

Clunietp
Dec 29th, 1999, 10:13 AM
You're not using the word.application.quit method. This example uses Word 9.0 (probably work in 8 as well)

Dim wd As Word.Application

Set wd = New Word.Application

wd.Documents.Open "D:\My Documents\Address.doc"
wd.Documents.Close False

wd.Application.Quit
Set wd = Nothing


Winword is removed from memory, as shown by my close program box.

HTH

Tom

Tonatiuh
Dec 29th, 1999, 09:58 PM
Thanks Tom,

But, I have a nother problem now.

objWord.Documents.Open "Doc1.doc"
objWord.PrintOut
DoEvents
objWord.Documents.Close
objWord.Quit
Set objWord = Nothing


And I recive this message:
Word is currently printing. Quitting Word will cancel all pending print jobs. Do you want to quit Word?

If I choose NO. Prints OK but doesn't quit it.

If I choose Yes. It quits Word OK but doesn't prints.

Is there any way to know when Word print job has finished?

Really thanks!

Happy New Year!

RogerH
Dec 29th, 1999, 10:35 PM
Hi,

use

objWord.Documents.Open "Doc1.doc"
objWord.PrintOut False
DoEvents
objWord.Documents.Close
objWord.Quit
Set objWord = Nothing


The False parameter after PrintOut prevents Word from printing in background and it will return to your code when printing is fully completed.

Happy New Year
Roger

Tonatiuh
Dec 30th, 1999, 12:00 AM
Thanks for your note Roger,

Tom, also put the false but, I ignored.

Thanks to both!