Forum Discussion

mm_achar's avatar
15 years ago

Unable to access the excel file

Hello,



I am using MS Excel as my test case file. I load in the run time and execute all the test cases file and then exit the function. But if the sometimes due to script error if the test execution is stopped in the middle and then manually restarted, I am getting the error Unable to access the test case file by TC. Then I have to close TC and restart to get access to my test case file again. I guess this probably due to the non-release of the object from the memory which is pointing to the test case file. Is there any way of trouble shooting this problem through the script or TC configurations...




- Madhu 

  • Hi,



    Exactly how are you working with your Excel file (via DDT, COM, etc.)? What exact error do you get?

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Madhu,



    It is highly probable, that Excel process remains in memory and keeps the file locked. Check with Task Manager if Excel process exists and terminate it if it does. You should be able to re-run the test after that without necessity to restart TestComplete.
  • I have the same issue I have tried all of the following to unlock the file without restarting TC, and none work:



    I have closed all excel processes

    removed the excel db file

    remove any temp files

    In computer management closed the file there

    Sharing the excel file

    Closing the TC project which was acessing the file (with TC still open)

    Update access database file



    Finally while using a search tool called ultra search, I found that there is a tmp file which is created by test complete - which I cant remove while test complete is running, and i have to shut it down - that file disappears on closing of test complete, and then i can edit the excel file   I am using the file with keyword tests and scripts and it would take a lot of time to switch all keyword scripts which are using excel data to scripted (which is the only suggestion I have had from support).  The support case was closed because i apparently didint reply in time - (within 12 hrs of receiving an email asking if they could clsoe it - my reply bounced back as the case reference was already closed)



    I am sure that TestComplete is locking the file, as it will not unlock no matter what I do, until I restart tc. that this is what is causing the issue.  



    Its a major pain and wastes a lot of time.



    To me if a product is stated to work with excel files, then itis a bug if that product locks the excel files up (even when you share them - and unsharing does not fix it either)  which needs to be fixed so that the functionality that the product claims with keyword testing and be used without this much pain.





  • I'm also working with Excel via COM but never faced locking issue. I've used following lines of code before working with Excel File, may be it will help you.




    excel = Sys.WaitProcess('EXCEL');

    if(excel.Exists)

      excel.Terminate();



    try

    {

      MsExcel = S
    ys.OleObject("Excel.Application");

    }

    catch(exception)

    {

      Log.Warning("Unable to initialize MS Excel.", "", pmHigher);

      return;

    }



    // rest of the code opening workbook and visible excel here.