use below query to terminate the process from task manager

strComputer = "."
 Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

 Set colProcesses = objWMIService.ExecQuery ("Select * from Win32_Process
Where Name = 'Excel.exe'")
 For Each objProcess In colProcesses
     objProcess.Terminate()
 Next


On Sun, Jun 16, 2013 at 12:16 PM, Aneel <[email protected]> wrote:

> Hi All Experts,
>
> I want to close all excel sheet that i opened through VB script.
> I am using below code for fetching the data from excel but after executing
> the code i observed the Excel.exe still displays in Task Manager
>
> For Ex.
> Set objFSO = createobject("Scripting.Filesystemobject")
> Set objexcel = createobject("Excel.Application")
> If objFSO.fileexists("C:\aneel.xlsx")Then
> objexcel.workbooks.open("C:\aneel.xlsx")
> strrowcnt= objexcel.worksheets("Login Sheet").usedrange.rows.count
> strcolcnt= objexcel.worksheets("Login Sheet").usedrange.columns.count
> For I= 1 to strrowcnt
>   For J = 1 to strcolcnt
>    Strval =  objexcel.worksheets("Sheet1").cell(i,j).Value
>    msgbox Strval
>   Next
> Next
>
>
> Set objFSO = Nothing
> Set objexcel = Nothing
>
> Thanks and Regards,
> Aneel
>
>  --
> --
> You received this message because you are subscribed to the Google
> "QTP - HP Quick Test Professional - Automated Software Testing"
> group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/MercuryQTP?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "QTP - HP Quick Test Professional - Automated Software Testing" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en

--- 
You received this message because you are subscribed to the Google Groups "QTP 
- HP Quick Test Professional - Automated Software Testing" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to