cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Code not working

HaoLu
Level 3
16040.jpg

I want to select the "* All Cost Elements" from the "wnd[0]/usr/lbl[xx,xx]" which is a variant ,so i have codes likes below :

dim SapGuiAuto as Object
dim application as Object
dim connection as object
Dim session as object

SapGuiAuto = GetObject("SAPGUI")
application = SapGuiAuto.GetScriptingEngine
connection = application.Children(0)
session = connection.Children(0)

Dim i As Integer = 2
Dim Found As Boolean = False
Do while not session.findById("wnd[0]/usr/lbl[5," & i & "]") is Nothing And Not Found
If session.findById("wnd[0]/usr/lbl[5," & i & "]").text = "* All Cost Elements" Then
Found = True
session.findById("wnd[0]/usr/lbl[5," & i & "]").setFocus
session.findById("wnd[0]/usr/lbl[5," & i & "]").caretPosition = 21
session.findById("wnd[0]").sendVKey (2)
Else
i += 1
End if
Loop


But everytime when i run the code ,it will report me "The control could not be found by id." .





------------------------------
Hao Lu
------------------------------
0 REPLIES 0