Search code examples
vbasap-gui

Get the total of a column using sap gui


Have a question that I just cant find an answer for. I have this value displayed (in yellow):

enter image description here

It's the total of the values in the column. Do you know how I can just get this value ? Usually in my macro I export the entire table in a excel workbook, open it and find the value of the last cell. I there an easier and faster way of getting it ?

Thanks


Solution

  • As the OP did not post any code I can only guess by the screen shot that the last row of a grid view should be retrieved.

    The following code snippet should do this. Assumption is that the variable ses is connected to the right session depicted in the OP's screenshot

    dim ses as object
    ' here code to connect to the sap session
    
    dim tbl as object
    set tbl = ses.findById("wnd[0]/usr/cntlGRID1/shellcont/shell")
    With tbl
       .firstVisibleRow = .rowCount -1
       Debug.Print  .getcellValue (.rowCount -1, "COLNAME")
    End With