Private Sub CommandButton2_Click()
Msg = "Attention " & Application.UserName & " !" & vbCrLf & "Please enter SAP User Id & Password. Thank you."
MsgBox Msg, vbCritical, "SAP Logon at PRD"
a = InputBox("User ID:", "SAP User ID:", "", vbOKCancel)
Sheet2.Cells(30, 1) = a -This can be wrong
i = InputBox("Password", "SAP Password:", "", vbOKCancel)
Sheet2.Cells(31, 1) = i -This can be wrong
Dim SapGuiApp As Object
Dim oConnection As Object
Dim session As Object
Dim SAPCon As Object, SAPSesi As Object
Dim SAPGUIAuto As Object, SAPApp As Object
'Dim sapConnection As Object
If SapGuiApp Is Nothing Then
Set SapGuiApp = CreateObject("Sapgui.ScriptingCtrl.1")
End If
If oConnection Is Nothing Then
Set oConnection = SapGuiApp.OpenConnection("L&R General Ledger – PRD", True)
End If
If SAPSesi Is Nothing Then
Set SAPSesi = oConnection.Children(0)
End If
With SAPSesi
.findById("wnd[0]/usr/txtRSYST-MANDT").Text = "100"
.findById("wnd[0]/usr/txtRSYST-BNAME").Text =
Sheet2.Cells(30, 1) -This can be wrong
.findById("wnd[0]/usr/pwdRSYST-BCODE").Text =
Sheet2.Cells(31, 1) - This can be wrong
.findById("wnd[0]/usr/txtRSYST-LANGU").Text = "EN"
.findById("wnd[0]").sendVKey 0
End With
End Sub
Bookmarks