我需要在VBA下使用脚本来查找SAP中文本框的字段名称引用!
Gridview没有显示名称!
Dim GridView As Object
If Not IsObject(SapAPP) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set SapAPP = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(SAPConn) Then
Set SAPConn = SapAPP.Children(0)
End If
If Not IsObject(session) Then
Set session = SAPConn.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject SapAPP, "on"
End If
session.FindById("wnd[0]").resizeWorkingPane 150, 31, False
session.FindById("wnd[0]").resizeWorkingPane 150, 31, False
session.FindById("wnd[0]/tbar[0]/okcd").Text = "cn46n"
session.FindById("wnd[0]").SendVKey 0
session.FindById("wnd[0]/usr/ctxtCN_PROJN-LOW").Text = "P-312313"
session.FindById("wnd[0]/usr/ctxtCN_NETNR-LOW").Text = "13123123"
session.FindById("wnd[0]/usr/ctxtCN_NETNR-LOW").SetFocus
session.FindById("wnd[0]/usr/ctxtCN_NETNR-LOW").CaretPosition = 7
session.FindById("wnd[0]/tbar[1]/btn[8]").press
session.FindById("wnd[0]/usr/cntlALVCONTAINER/shellcont/shell").CurrentCellColumn = "STATXT"
session.FindById("wnd[0]/shellcont/shellcont/shell/shellcont[1]/shell/shellcont[1]/shell").TopNode = " 23"
'Set GridView = session.FindById("wnd[0]/shellcont/shellcont/shell/shellcont[1]/shell/shellcont[1]/shell")
Set GridView = session.FindById("wnd[0]/usr/cntlALVCONTAINER/shellcont/shell/shellcont[1]/shell/shellcont[1]/shell")
session.FindById("wnd[0]/tbar[0]/btn[15]").press
通常使用gridview我可以看到文本字段名称是什么,并提取我需要的东西,如... MsgBox(“PSPID =”)& GridView.GetCellValue(i,“PSPID”)
但我无法找到正确识别字段的方法。
答案 0 :(得分:1)
您可以尝试以下方法:
for i = 0 to 9
msgbox "test = " & Session.FindById("wnd[0]/usr/tabsTABCJLE/tabpLEGR/ssubLISTE:SAPLCJWB:0902/tblSAPLCJWBTAB_902/txtPRPS-POST1[3," & cstr(i) & "]").text
...
此致 ScriptMan