Last active
February 8, 2023 00:55
-
-
Save khanhkhuu/2fa65143fa95f5ae5aaecc2cc1f85bd7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Private SapGuiAuto | |
Private objGui As GuiApplication | |
Private objConn As GuiConnection | |
Private win As GuiFrameWindow | |
Public ConnectionString As String | |
Public HideGui As Boolean | |
Public session As GuiSession | |
Public Sub OpenSAP() | |
Set SapGuiAuto = CreateObject("Sapgui.ScriptingCtrl.1") | |
If (HideGui) Then ConnectionString = ConnectionString & "/INPLACE" | |
Set objConn = SapGuiAuto.OpenConnection(ConnectionString, True) | |
Set session = objConn.Children(0) | |
Set win = session.ActiveWindow | |
If win.Text = "License Information for Multiple Logon" Then | |
session.FindById("wnd[1]/usr/radMULTI_LOGON_OPT2").Select | |
session.FindById("wnd[1]/tbar[0]/btn[0]").Press | |
End If | |
Set win = session.ActiveWindow | |
If win.Text = "Information" Then | |
session.FindById("wnd[1]/tbar[0]/btn[0]").Press | |
End If | |
End Sub | |
Public Sub AttachSAP() | |
Set SapGuiAuto = GetObject("SapGui") | |
Set objGui = SapGuiAuto.GetScriptingEngine | |
Set objConn = objGui.Children(0) | |
Set session = objConn.Children(0) | |
End Sub | |
Public Sub CloseSAP() | |
Set session = Nothing | |
Set objConn = Nothing | |
Set SapGuiAuto = Nothing | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment