on 07-20-2015 3:14 PM
Hi everyone,
I am trying to enter some data in SAP PRA module through excel VBA. Upon recording script and putting in excel macro, i am experiencing VBA runtime error-613 "Method has got an invalid argument". There is a combo box control, which has to be set to a key "11F4", but the combobox does not load any list while executing through VBA.
Below is the code, kindly help
Dim sapguiapp As Object, oconnection As Object, sapsesi As Object
If sapguiapp Is Nothing Then
Set sapguiapp = CreateObject("Sapgui.ScriptingCtrl.1")
End If
If oconnection Is Nothing Then
Set oconnection = sapguiapp.OpenConnection("RP1 [ICE-Other Module]", True)
End If
If sapsesi Is Nothing Then
Set sapsesi = oconnection.Children(0)
End If
With sapsesi
.findById("wnd[0]").iconify
.findById("wnd[0]/usr/txtRSYST-MANDT").Text = "500"
.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "91984"
.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "mindblow"
.findById("wnd[0]/usr/txtRSYST-LANGU").Text = "EN"
.findById("wnd[0]/tbar[0]/btn[0]").press
23 If .Children.Count > 1 Then
.findById("wnd[0]").sendVKey 0
End If
If .Children.Count > 1 Then GoTo 23 Else GoTo 24
24 .findById("wnd[0]").iconify
.findById("wnd[0]").sendVKey 0
.findById("wnd[0]").maximize
If IsObject(wscript) Then
wscript.ConnectObject session, "on"
wscript.ConnectObject Application, "on"
End If
.findById("wnd[0]").maximize
.findById("wnd[0]/tbar[0]/okcd").Text = "ZPRARECDWNHRS"
.findById("wnd[0]").sendVKey 0
.findById("wnd[0]/usr/radG_S_SELECTION-OFFSHORE").Select
.findById("wnd[0]/usr/cmbG_S_SELECTION-WERKS").SetFocus
''below is the line where error occurs
.findById("wnd[0]/usr/cmbG_S_SELECTION-WERKS")..key="11F4"
.findById("wnd[0]").sendVKey 0
I tried whatever i could, but no success.Please help
Thanks
Hello.
I can see you open a session with Sapgui.ScriptingCtrl.1 object. This have not same Options as an session opened with SAPGUI direct. I guess you use an script recording from a normal session. This could be why it fail. May you should adopt yourVBA code to an existing session and check if this will solve your issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI, thanks for the reply. Please tell me if i need to add some references to VBA to get the desired result. I have earlier made a project, where i log in to sap through excel vba userform in a way that the user never knows that sap window is actually active anytime and data entry is done into sap. I want the similar kind of project to be done this time, but am stuck with combo box selection error. Plese help me.
regards
raj kumar pathak
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.