PDA

Click to See Complete Forum and Search --> : Ending a process in NT


slithey
Oct 20th, 2001, 05:08 AM
Help! I want to convert a Word.doc to a Word.rtf for use in the MS richtextbox control.

I'm doing: -

Dim wdDoc As Word.Document
Set wdDoc = GetObject("c:\cvs\CV.doc")
wdDoc .SaveAs "C:\cvs\temp\CV.rtf", wdFormatRTF
Set wdDoc = Nothing

Which works fine, except it leaves an orphan instance of WINWORD.EXE running in the processes window of task manager (NT 4). Also, this leaves an orphan ~$CV.doc and ~$CV.rtf file on the drive, and I can't open the RTF file straight away, as it's locked by WINWORD.EXE. GetObject(,"word.application"0 returns an error, so I can't use thsi to close it, and there's no Word instance window, so I can't use that method to close it either.

I've then used an API call to the kernel32 library to copy the file somewhere else, so I can open it and, on exiting the application, I fugure I'll delete the temp folder. However, the WINWORD.EXE instance, which hangas about indefinitely, prevents deletion, 'cos it's still got lock on the original CV.rtf file.

So - my questions are: -

- is there a better way to convert .doc to .rtf? My users won't have Word on their PCs, but I am hoping that distribution of the word9 object library will do the job (large though it is).

- how can I close the WINWORD.EXE process assuming GetObject(,"word.application") returns nothing, 'cos the users isn't using Word for something else?

Please - any ideas appeciated!

numtel
Oct 20th, 2001, 10:58 PM
The security in NT is too much, u cant close a process with the api.