Forum Discussion

cristina88's avatar
cristina88
Occasional Contributor
9 years ago

How to close an excel window in web application

I have an Excel window (from a Web Application) that pops up from clicking an Export button. 

I've recorded this step and even give the excel window focus and then click either cancel or close.   When executing the test, I get either error: 

1.  "There was an attempt to perform an action on a zero-sized window" 

 

OR

 

2. "There was an attempt to perform an action at point (#, #) which is overlapped by another window".

 

Can TestComplete close this excel window. Any helpful hints, workarounds, suggestions etc. to try? 

 

Thanks in Advance!

Cristina

3 Replies

  • If you don't really care about interacting with the window, our automation suite has the following snippet of code that shuts down Excel completely. I have it in a script file and call it when I want to close down Excel.

     

    function CloseExcel()
    {
    p = Sys.FindChild("ProcessName", "EXCEL*");
    Log.Message('Starting Excel close process');
    while (p.exists)
    {
    p.Close();
    //Wait until the process is closed.
    isClosed = p.WaitProperty("Exists", false);
    //If closing failed, terminate the process.
    if (isClosed == false)
    {
    Log.Message('isClosed is still false');
    p.Terminate();
    }
    p = Sys.FindChild("ProcessName", "EXCEL");
    }

    Log.Message('Excel close process successfully terminated');
    }