I have a similar problem, and I would like to know if your solution worked. I am trying to use the code below for my structure, but I have not had success yet. Can you help me?
Basically, what I need to do is select the tree item by name and then set its checkbox to true. Because when recording the script directly through SAP, it searches for the file by its Child identifier, as below:
session.findById("wnd[0]/usr/cntlTREE_CONTAINER/shellcont/shell").selectItem "Child12","2"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER/shellcont/shell").ensureVisibleHorizontalItem "Child12","2"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER/shellcont/shell").changeCheckbox "Child12","2",true
session.findById("wnd[0]/usr/btnVALIDAR").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/cntlTREE_CONTAINER/shellcont/shell").selectItem "Child11","1"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER/shellcont/shell").ensureVisibleHorizontalItem "Child11","1"
session.findById("wnd[0]/usr/cntlTREE_CONTAINER/shellcont/shell").changeCheckbox "Child11","1",true
session.findById("wnd[0]/usr/btnVALIDAR").press
My tree: enter image description here
MyCode
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
Set tree = session.findById("wnd[0]/usr/cntlTREE_CONTAINER/shellcont/shell")
Set ListNodeKeys = tree.getallnodekeys
For Each nodeKey In ListNodeKeys
If nodeText = "File_Name" Then
tree.selectItem (nodeKey)
tree.ensureVisibleHorizontalItem (nodeKey)
tree.changeCheckbox (nodeKey),true
End If
Next nodeKey