Skip to Content
avatar image
Former Member

Reading grid cells (SAP GUI Scripting - VBS)

If Not IsObject(application) Then
   Set SapGuiAuto  = GetObject("SAPGUI")
   Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
   Set connection = application.Children(0)
End If
If Not IsObject(session) Then
   Set session    = connection.Children(0)
End If
If IsObject(WScript) Then
   WScript.ConnectObject session,     "on"
   WScript.ConnectObject application, "on"
End If
dim sapRow
sapRow = 0
Set GRID1 = session.FindById("wnd[0]/usr/cntlGRID1/shellcont/shell")
'session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").currentCellRow = 9
For sapRow = 0 to GRID1.rowCount - 1
'on error resume next
Value = GRID1.GetCellValue(sapRow,"Notification") - I  get an error on this line
Good Day!

I am trying to learn SAP Scripting to automate some of the tasks that we have in SAP.

I want to read grid cells and to check if there is an existing notification in SAP based on the description of each notification. I am getting an error when I try to do a loop to check each available row for any matches. I am not sure on how to store the content of the Notification column into a variable. Any help would be appreciated.

Thank you.

sap.jpg (138.4 kB)
error.jpg (43.3 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Sep 14, 2017 at 10:23 AM

    Hi Nicolas,

    it might be that the internal column name is quite different. But you can get it out. For example, you can use the script recorder to record a sort for that column. The name you are looking for is then in the script.



    Add comment
    10|10000 characters needed characters exceeded

  • Sep 14, 2017 at 01:10 PM

    Hello Nicolas,

    welcome here in the forum.

    I wrote a blog about this requirement, you can find it here. With the solution I described you can read any grid and get the content of each cell.

    Let us know your results.


    Add comment
    10|10000 characters needed characters exceeded