I've been searching on my own and I've failed so far, I already tried changing the line "Set session = Connection.Children()" "to Set session = Connection.Children(0)" or 1 but no progress so far...
My version of the SAP is 6.0
Here's the full code that I've tried so far
Any help would be appreciated
My version of the SAP is 6.0
Here's the full code that I've tried so far
VBA Code:
Private Sub SapConn()
Dim Appl As Object
Dim Connection As Object
Dim session As Object
Dim WshShell As Object
Dim SapGui As Object
'file directory
Shell "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe", 4
Set WshShell = CreateObject("WScript.Shell")
Do Until WshShell.AppActivate("SAP Logon ")
Application.Wait Now + TimeValue("0:00:01")
Loop
Set WshShell = Nothing
Set SapGui = GetObject("SAPGUI")
Set Appl = SapGui.GetScriptingEngine
Set Connection = Appl.Openconnection("1.1 - Sap ECC Leader Produção.", _
True)
Set session = Connection.Children()
'username and password
'BELOW I'M GETTINT ERROR NUMBER 438
session.findById("wnd[0]/usr/txtRSYST-MANDT").Text = "400" '<<<< HERE
session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "mylogin" '<<<< HERE
session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "mypass" '<<<< HERE
session.findById("wnd[0]/usr/txtRSYST-LANGU").Text = "PT" '<<<< HERE
If session.Children.Count > 1 Then
answer = MsgBox("You've got opened SAP already," & _
"please leave and try again", vbOKOnly, "Opened SAP")
session.findById("wnd[1]/usr/radMULTI_LOGON_OPT3").Select
session.findById("wnd[1]/usr/radMULTI_LOGON_OPT3").SetFocus
session.findById("wnd[1]/tbar[0]/btn[0]").press
Exit Sub
End If
session.findById("wnd[0]").maximize
session.findById("wnd[0]").sendVKey 0
Any help would be appreciated