I have the following code for connecting SAP logon with VBA
Private Sub CommandButton1_Click()
Dim SAPapplication, Connection, session As Object
Set SAPGUIAuto = GetObject("SAPGUI")
Set SAPapplication = SAPGUIAuto.GetScriptingEngine
Set Connection = SAPapplication.Children(0)
Set session = Connection.Children(0)
session.findById("wnd[0]").maximize
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[0]/okcd").Text = "******"
session.findById("wnd[0]").sendVKey 0
The code works perfectly if I have login through my credentials in the SAP system. But it gives following error, when I try login through other credentials.
Run-time error '-2147221020 (800401e4)':
Automation error
Invalid syntax
What is the problem here?