Results 1 to 27 of 27

Thread: Excel 2002 won't die, using Automation

Threaded View

  1. #25
    Addicted Member
    Join Date
    Jan 2006
    Location
    Montreal, Canada
    Posts
    152

    Re: Excel 2002 won't die, using Automation

    Quote Originally Posted by l33t_c0w
    If I kill it there seem to be no ill effects and then everything runs well, but that isn't an option unless I can be sure that I'm killing the right process.
    Here is how you can kill the right process.

    First, after you started the Excel process that you want to kill (the first one I think) call this function

    VB Code:
    1. Declare Function GetCurrentProcessId Lib "kernel32" () As Long

    This function return the process ID of the Excel process just created.
    Put the result in a variable

    Once you have done everything you want to do and want to kill the god dam process

    do

    VB Code:
    1. Function KillPId()
    2.  
    3.         Set ProcessList = GetObject("winmgmts://.").InstancesOf("win32_process")
    4.  
    5.     For Each Process In ProcessList
    6.         If Process.ProcessID = variable Then ' variable = the processID obtain by the GetCurrentProcessId function
    7.                           Process.Terminate
    8.         End If
    9.     Next
    10.  
    11.     End Function

    Hope it will helps a bit
    Last edited by billhuard; Apr 5th, 2006 at 09:37 AM.

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