Forum Discussion

Kamal_chennai's avatar
Kamal_chennai
Contributor
9 years ago
Solved

How to copy whole Excel workbook content

Hi,

 

I want to copy all the rows and columns from Excel Worksheet to my TestComplete clipboard. I just tried with 

aqFile.ReadWholeTextFile(PathTextCodingType) but i didn't get the correct words. FYI Find the Screen shot

 

Capture.png

 

Is there any way to implement?

 

Thanks in Advance

Kamal

  • You can do this using the Excel COM object, Excel.Application.

     

    // JScript
    function Test()
    {
      var oExcel = Sys.OleObject("Excel.Application");
      var oWb = oExcel.Workbooks.Open("C:\\Work\\TestBook.xlsx");
      oWb.ActiveSheet.UsedRange.Copy();
      oWb.Close();
      oExcel.Quit();
    
      Log.Message("See Additional Info", Sys.Clipboard);
    }

2 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    You can do this using the Excel COM object, Excel.Application.

     

    // JScript
    function Test()
    {
      var oExcel = Sys.OleObject("Excel.Application");
      var oWb = oExcel.Workbooks.Open("C:\\Work\\TestBook.xlsx");
      oWb.ActiveSheet.UsedRange.Copy();
      oWb.Close();
      oExcel.Quit();
    
      Log.Message("See Additional Info", Sys.Clipboard);
    }