vbasap-gui

SAP GUI scripting VBA - Button press is ignored


I am using SAP GUI 7.50 and running the script from Excel. I recorded a script for transaction ZC9_SE16_MAT table MARA. I want to select multiple material numbers, but pressing the button with the recorded script is ignored (does not open new window). The button is marked in the image. How can I open that window?

Button not working

' Connect to SAP
Set SapGuiAuto = GetObject("SAPGUISERVER")
Set SAPApp = SapGuiAuto.GetScriptingEngine
If Not IsObject(Connection) Then
       Set Connection = SAPApp.Children(0)
End If
If Not IsObject(session) Then
   Set session = Connection.Children(0)
End If
If Not IsObject(Connection) Then
   Set Connection = SAPApp.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

' Start Transaction
session.StartTransaction "ZC9_SE16N_MAT"
' Confirm Mara
session.findById("wnd[0]").sendVKey 8

' Press the button
session.findById("wnd[0]/usr/tblSAPLZ_C9_SE16NSELFIELDS_TC/btnPUSH[4,1]").SetFocus
' Bellow line does not work
session.findById("wnd[0]/usr/tblSAPLZ_C9_SE16NSELFIELDS_TC/btnPUSH[4,1]").press

The last line does not work.

I saw similar problem in this post, but the answer did not work for me.


Solution

  • I found a solution for my problem, but is not perfect. Press Shift + F11, which turns Technical View On. Then there appears option Ctrl + F9, which open window Multiple Entry. This new window looks very similar to the first window, but now recorded press on the button works.

    This solved my problem, but I would still like to know how to press on the first button so if anyone knows please add answer.