79334290

Date: 2025-01-06 20:49:49
Score: 11.5 🚩
Natty:
Report link

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     

Reasons:
  • Blacklisted phrase (1.5): I would like to know
  • Blacklisted phrase (1): help me
  • Blacklisted phrase (1): I have a similar problem
  • Blacklisted phrase (0.5): I need
  • Blacklisted phrase (1): I am trying to
  • Blacklisted phrase (1): enter image description here
  • RegEx Blacklisted phrase (3): Can you help me
  • Long answer (-1):
  • Has code block (-0.5):
  • Me too answer (2.5): I have a similar problem
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Leonardo Batista