Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Talend Cloud AWS EU Scheduled Outage: Starting Tues 26 May 21:00 CEST with expected completion Wed 27 May 01:00 CEST
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.

Labels (1)
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
MVP
MVP

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