[RESOLVED] URGENT - creating word object with office.interops
I am using the office interop to open word documents and saving as html to do parsing work. After a few executions I notice that in the task manager under processes there are still instances of WINWORD.EXE running. I have used the
following to close the object but it is still there:
Code:
wordApp.Quit()
wordApp = Nothing
How do I close this in order to avoid overhead? Any ideas appreciated
Re: creating word object with office.interops
I had similar probelm with Excel...
You can do like i did, something like when start the process get the process id, and when you want quit, after saving and done everything you need, just call the kill method of the process...
Re: creating word object with office.interops
Thanks for the response; do you mean create a process when running the specific function or are you referring to the word.application.
Pardon my ignorance
Re: URGENT - creating word object with office.interops
I'm referring to the application...
Here what i do in excel:
VB.NET Code:
'Declare the function GetWindowThreadProcessID
Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As IntPtr, ByRef lpdwProcessId As IntPtr) As IntPtr
...
prgExcel = New Excel.Application
Dim inProcess As IntPtr 'To save the pointer to the process
Dim inHandle As IntPtr = prgExcel.Hwnd 'Handle
GetWindowThreadProcessId(inHandle, inProcess)
Dim processExcel As Process = Process.GetProcessById(inProcess.ToInt64)
...
'To close the application, if you call the quit and the application still open, just call the kill method
processExcel .Kill()