Search code examples
vbarowssap-gui

Get the value of an output screen field


In view of counting how many rows I have in my table, I usually export it via VBA in excel then count the rows. Is there any way to get it directly from SAP GUI?

I tried to get it by .VerticalScrollbar.Maximum, but unless I don't use it properly, it didn't give me the right number...

ScrollBar = session.findById("wnd[0]/usr").VerticalScrollbar.Maximum
MsgBox ("ScrollBar= " & ScrollBar)

In other words:

In this filed I have 316 rows (counted with the excel export); .VerticalScrollbar.Maximum gives me 267 rows. Where are the 49 rows left in my count ? enter image description here

I also found out that that this "information" button enter image description here make this window appear:

enter image description here

And these two numbers make the 316 I'm looking for: 395-79 = 316 So I tried to interact with this window while recording a macro and it only saves this interaction:

session.findById("wnd[1]/usr/sub/1[0,0]/sub/1/6[0,10]/sub/1/6/8[0,14]/lbl[28,14]").setFocus
session.findById("wnd[1]/usr/sub/1[0,0]/sub/1/6[0,10]/sub/1/6/8[0,14]/lbl[28,14]").caretPosition = 0

No way to copy these numbers...

Edit: clarifactions

Thanks for reading and have a good day!


Solution

  • session.findById("wnd[1]/usr/sub/1[0,0]/sub/1/6[0,10]/sub/1/6/8[0,14]/lbl[28,14]").text
    

    Worked well.

    @sandra-rossi : Thanks !