Forum Discussion

Audrey's avatar
Audrey
Occasional Contributor
3 years ago

Insert picture in Excel

Hi, may i know how to insert picture in excel using keyword test? I notice there are limited operations for excel in keyword test

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    No way to do this via existing set of operations for keyword tests. Only through the code.

     

  • Hello,

     

    Can somebody please help on  how to insert picture in Excelsheet , through code?.

     

    Thanks.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    In your Project properties, add the WndClass name of the ribbon to MSAA in Open Applications. I’m using Excel 365 and my WndClass is called ‘NetUIHWND’. TestComplete will then recognise each of the menu items in the ribbon.

    Record your keyword test as click Insert -> Pictures -> select file -> Insert

    The same can be applied when scripting

    function Test8()
    {
      Aliases.EXCEL.wndXLMAIN.EXCEL2.toolbar.Ribbon.NUIPane.NetUIHWND.tablistRibbonTabs.ClickTab("Insert");
      Aliases.EXCEL.wndXLMAIN.EXCEL2.toolbar.Ribbon.NUIPane.NetUIHWND.paneLowerRibbon.client.propertypageInsert.toolbarIllustrations.buttonPictures.ClickButton();
      Aliases.EXCEL.dlgInsertPicture.OpenFile("C:\\Users\\Test\\Pictures\\Smartbear.jpg", "All Pictures (*.emf;*.wmf;*.jpg;*.jpeg;*.jfif;*.jpe;*.png;*.bmp;*.dib;*.rle;*.gif;*.emz;*.wmz;*.tif;*.tiff;*.svg)");
    }