on 01-14-2013 5:52 PM
Hi Experts,
Could you please anyone provide the VBA code to connect SAP through EXCEL.
Thanks in advance.
Arun
On Error Resume Next
If Not IsObject(SAP_applic) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set SAP_applic = SapGuiAuto.GetScriptingEngine
End If
er = Err.Number
On Error GoTo 0
If er <> 0 Then
er = 0
On Error Resume Next
Set sapSHShell = CreateObject("WScript.Shell")
quotes = Chr(34)
sapSHShell.Run quotes & "C:\Program Files\SAP\FrontEnd\SAPgui\saplgpad.exe" & quotes, 2, False
On Error GoTo 0
waitTill = Now() + TimeValue("00:00:01")
While Now() < waitTill
DoEvents
Wend
er = 0
On Error Resume Next
If Not IsObject(SAP_applic) Then
Set SapGuiAuto = GetObject("SAPGUI") 'Setting
Set SAP_applic = SapGuiAuto.GetScriptingEngine
End If
er = Err.Number
On Error GoTo 0
If er <> 0 Then
tmp = MsgBox("SAP Logon not installed on your system" & vbCrLf & _
"Please install it using eSupport!", vbInformation)
End
End If
End If
Set Connection = SAP_applic.openconnection("GIJ")
Set Session = Connection.Children(0)
Session.findById("wnd[0]").resizeWorkingPane 148, 21, False
Session.findById("wnd[0]").maximize
Session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "username"
Session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "password"
Session.findById("wnd[0]/usr/pwdRSYST-BCODE").SetFocus
Session.findById("wnd[0]/usr/pwdRSYST-BCODE").caretPosition = 8
Session.findById("wnd[0]").sendVKey 0
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
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.