Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
nihhalmca
Specialist II
Specialist II

How To Kill "Excel.exe" Process by Macro

Hi All,

I want to kill "EXCEL.EXE" Process by Macro.

Could you pelase share VB Script (.VBS).

Thanks,

Nihhal.

1 Solution

Accepted Solutions
Frank_Hartmann
Master II
Master II

I think this should terminate the EXCEL.EXE:

Sub TerminateProcess

Dim Process

For Each Process In GetObject("winmgmts:").ExecQuery("Select Name from Win32_Process Where Name = 'EXCEL.EXE'")

   Process.Terminate

Next

End Sub

hope this helps!

View solution in original post

3 Replies
marcus_sommer

If possible try to terminate this process before (after excel finished the task to which it was created). If you really need to go further with this approach take a look here: Re: How to create kill QV task which you could adapt from qlik to excel.

- Marcus

Frank_Hartmann
Master II
Master II

I think this should terminate the EXCEL.EXE:

Sub TerminateProcess

Dim Process

For Each Process In GetObject("winmgmts:").ExecQuery("Select Name from Win32_Process Where Name = 'EXCEL.EXE'")

   Process.Terminate

Next

End Sub

hope this helps!

nihhalmca
Specialist II
Specialist II
Author

Thank you.

'1) User Define Function in VBS

Sub TerminateProcess 

Dim Process 

For Each Process In GetObject("winmgmts:").ExecQuery("Select Name from Win32_Process Where Name = 'EXCEL.EXE'") 

Process.Terminate 

Next 

End Sub

'2) Call when yoiu required for end process

TerminateProcess

Note : it will lost all un saved data