Skip to Content
0
Jun 27, 2022 at 03:11 PM

Control could not find by ID error for PressToolbarContextButton

98 Views

Hi,

I am new to SAP scripting and below is the issue I hope for your kind guidance here. Have browse through the forum but unable to find any similar post for my issue here

Below is the code SAP generated when I using the script recording and playback function. When I run the vb script without any amendment, it showing error "The control could not be found by ID" for the line below.

**session.findById("wnd[0]/usr/cntlCONT1/shellcont[0]/shell/shellcont[0]/shell").pressToolbarContextButton "&MB_EXPORT"

(not just the MB_Export function, have test with others toolbar button too but the script also not working.)

capture.png

Full code

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

session.findById("wnd[0]").maximize

session.findById("wnd[0]/tbar[0]/okcd").text = "ZMMAP_INV_BLOCK_AGED"

session.findById("wnd[0]/tbar[0]/btn[0]").press

session.findById("wnd[0]/usr/ctxtS_BUKRS-LOW").text = "xxxx"

session.findById("wnd[0]/usr/txtS_GJAHR-LOW").text = "xxxx"

session.findById("wnd[0]/usr/txtS_GJAHR-LOW").setFocus

session.findById("wnd[0]/usr/txtS_GJAHR-LOW").caretPosition = 4

session.findById("wnd[0]/tbar[1]/btn[8]").press

session.findById("wnd[0]/usr/cntlCONT1/shellcont[0]/shell/shellcont[0]/shell").pressToolbarContextButton "&MB_EXPORT"

session.findById("wnd[0]/usr/cntlCONT1/shellcont[0]/shell/shellcont[0]/shell").selectContextMenuItem "&XXL"

session.findById("wnd[1]").close

Attachments

capture.png (7.6 kB)