Results 1 to 4 of 4

Thread: [RESOLVED] URGENT - creating word object with office.interops

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2008
    Location
    USA
    Posts
    257

    Resolved [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
    Last edited by cengineer; Feb 27th, 2010 at 01:08 PM. Reason: urgent help needed

  2. #2
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

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

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2008
    Location
    USA
    Posts
    257

    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

  4. #4
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: URGENT - creating word object with office.interops

    I'm referring to the application...

    Here what i do in excel:
    VB.NET Code:
    1. 'Declare the function GetWindowThreadProcessID
    2.  Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As IntPtr, ByRef lpdwProcessId As IntPtr) As IntPtr
    3.  
    4. ...
    5.  prgExcel = New Excel.Application
    6.         Dim inProcess As IntPtr 'To save the pointer to the process
    7.         Dim inHandle As IntPtr = prgExcel.Hwnd 'Handle
    8.         GetWindowThreadProcessId(inHandle, inProcess)
    9.         Dim processExcel As Process = Process.GetProcessById(inProcess.ToInt64)
    10. ...
    11. 'To close the application, if you call the quit and the application still open, just call the kill method
    12. processExcel .Kill()

    Rate People That Helped You
    Mark Thread Resolved When Resolved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width