Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 10671

Re: Opening SAP using macro

$
0
0

Hello Saad,

 

'--------------------------Start Excel VBA Sub-----------------------------

 

Sub SAP_OpenSessionFromLogon()
Dim SapGui
Dim Applic
Dim connection
Dim session

 

Shell ("C:\Program Files\SAP\FrontEnd\SAPgui\saplogon.exe")

Set SapGui = GetObject("SAPGUI")

 

Rem Create the GuiApplication object
Set Applic = SapGui.GetScriptingEngine

 

Rem Open a connection
Set connection = Applic.OpenConnection("QE1 - ERP QA ECC 6.0", True) '<=== here you need to fillin your connection description

 

Set session = connection.Children(0)

session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/txtRSYST-MANDT").Text = "800"
session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "Test1"
session.findById("wnd[0]").sendVKey 0

 

Rem Do something: Either fill out the login screen
Rem or in case of Single-Sign-On start a transaction.
session.SendCommand ("/nbibs")

 

MsgBox "Waiting..."

 

Rem Shutdown the connection
Set session = Nothing
connection.CloseSession ("ses[0]")
Set connection = Nothing
Set sap = Nothing

MsgBox "Done"

End Sub

 

'--------------------------End of Excel VBA Sub----------------------------

 

Just fillin the description from your system in row where 'Set connection' is defined.

 

If you have any questions let me know. Br, Holger


Viewing all articles
Browse latest Browse all 10671

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>