Please help me to convert the following script from VBS to VBA (Excel Macro). Instead of open SAP log on and type User and Password every day. I want it to open it from an excel file.
Here is the current script I have, but for some reason the SAP popup screen does not remain open and the excel does not work after running it.
Sub LOGONSAP()
If Not IsObject(SAPguiApp) Then
Set SAPguiApp = CreateObject("Sapgui.ScriptingCtrl.1")
End If
If Not IsObject(Connection) Then
Set Connection = SAPguiApp.OpenConnection("MYSYSTEM", True)
End If
If Not IsObject(session) Then
Set session = Connection.Children(0)
End If
session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "MYUSER"
session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "MYPSSW"
session.findById("wnd[0]/usr/pwdRSYST-BCODE").SetFocus
session.findById("wnd[0]/usr/pwdRSYST-BCODE").caretPosition = 2
session.findById("wnd[0]").sendVKey 0
End Sub