1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
Option Explicit
Dim WSHShell, SAPGUIPath, SID, InstanceNo, WinTitle, SapGui, Appl, Connection, session
Set WSHShell = WScript.CreateObject("WScript.Shell")
If IsObject(WSHShell) Then
SAPGUIPath = "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\"
SID = "S-1-5-21-1993962763-299502267-1801674531-1190098"
InstanceNo = "00"
WSHShell.Exec SAPGUIPath & "saplgpad.exe " & SID & " " & _
InstanceNo
WinTitle = "SAP"
While Not WSHShell.AppActivate(WinTitle)
WScript.Sleep 250
Wend
Set WSHShell = Nothing
End If
Set SapGui = GetObject("SAPGUI")
Set Appl = SapGui.GetScriptingEngine
Set Connection = Appl.Openconnection("Test SAP", True)
Set session = Connection.Children(0)
session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "ID"
session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "PASSWORD"
session.findById("wnd[0]/usr/txtRSYST-LANGU").Text = "Fr"
session.findById("wnd[0]").sendVKey 0
MsgBox "Voilà ..." |
Partager