Hi Script man,
I hope you're fine and Thanks for your last clarification for my quest.
Now I need a help from you. I don't know how to open a new post and also i tried to send a direct message to you. But I couldn't. Thats why I place this query here. Please help.
I 'm using the follwing (your) code to connect Excel & SAP and have created many automations. All of them are working very fine except one.
The SAP window closes after macro run is completed.
Could you please provide me a code which will not close SAP window after macro run is finished.
And also please provide me a code to transfer data from Excel to a opened (manually) SAP window.
Your timely reply will help me more to work out.
Thanks ScriptMan.
Code:
Set SAP = CreateObject("SAP.Functions")
Set conn = SAP.connection
If Not IsObject(SapGuiApp) Then
Set SapGuiApp = CreateObject("Sapgui.ScriptingCtrl.1")
End If
If Not IsObject(connection) Then
Set connection = SapGuiApp.OpenConnection("051 - PRD - EP1", True)
End If
If Not IsObject(session) Then
Set session = connection.Children(0)
End If
UserName = InputBox("Please Enter Your User Name")
Password = InputBox("Please Enter password")
session.findById("wnd[0]/usr/txtRSYST-BNAME").text = UserName
session.findById("wnd[0]/usr/pwdRSYST-BCODE").text = Password
session.findById("wnd[0]").sendVKey 0