Closing 1 excel when multiple instances of excel are open during runtime in QTP

I have written a VB script to batch run the QTP scripts. My VB script takes input from the "ControlFile" excel to get the name of the test script to open and execute in QTP. So I need to keep this "ControlFile" excel open throughout the execution of all the scripts in the batch. The problem is my scripts open some excel for comparison and when they are closed with appexcel.Quit, even my "ControlFile" excel closes and hence I am unable to get the scriptnames after that. The execution stops here. Can anyone please help me with this, to close 1 particular instance of an excel during runtime.
Thanks in Advance for the help!

Showing Answers 1 - 2 of 2 Answers

Suraj Kumar Patra

  • Jan 18th, 2012

Try this one

  1.  SystemUtil.CloseProcessByHwnd"Hwndvalue"

  2. Exp:

  3. SystemUtil.CloseProcessByHwnd"132638"

  Was this answer useful?  Yes


  • Feb 5th, 2012

You can find all the instances of open excels using GetObject() or Desktop.ChildObjects method. Then iterate through the list of objects and find the required excel using some property (like excel title). Once the required excel is found, you can close that excel object.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.


Related Answered Questions


Related Open Questions