Forum Discussion

socc3rpr0's avatar
socc3rpr0
Occasional Contributor
11 years ago

Crop Picture with Excel 2007 via COM Server

Hello,  I can seem to figure out how to crop a picture after I insert it from a location onto a worksheet. I can get the code to run in VB macro, but not with TestComplete. Can someone guide me...
  • googleid_118035's avatar
    11 years ago

    Hi Ed Gonzales,


     


    Try using following functions,


     


    function Test() {


    crop_image("C:\\Dev_Chaminda\\QA\\Automation_Testing\\TestComplete\\TestData\\UserName.xls","Sheet2",50,500)


    }


    function crop_image(filepath,sheetname,heightval,widthval){


    var excel=new ActiveXObject("Excel.Application");


    excel.DisplayAlerts = false; 


    var excel_file = excel.Workbooks.Open(filepath);


    var excel_sheet = excel_file.Worksheets(sheetname);


    excel_sheet.Pictures.ShapeRange.Height = heightval


    excel_sheet.Pictures.ShapeRange.Width = widthval


    excel_file.Save;


    excel_file.Close;


    excel.Exit;


    }