Selection of correct SAP window using Taskbar
I have an issue in selecting the right sytem by using macro.
I have 3 system open RP1, BP1 and SP1, but have to open RP1 sytem to run the macro further.
In the macro done by me, i can open the desired system only if it is the first open window.
The below is the codes for your ready reference.
If Not IsObject(Application1) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set Application1 = SapGuiAuto.GetScriptingEngine
If Not IsObject(Connection) Then
Set Connection = Application1.Children(0)
If Not IsObject(session) Then
Set session = Connection.Children(0)
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject Application1, "on"
Kindly let me know, how can i open the required window using the sytem name eg " SP1 (1) 510 " , by refering to the taskbar where it is displayed.
I need to open these windows from time to time to run my macro, hence need to refer them using the sytem name.
Script Man replied
I suspect however that the solution looks like this:
If Not IsObject(application) Then Set SapGuiAuto = GetObject("SAPGUI") Set application = SapGuiAuto.GetScriptingEngine End If for connection_number = 0 to application.children.count - 1 Set connection = application.Children(int(connection_number)) Set session = connection.Children(0) if session.info.systemname = "SP1" then exit for next msgbox session.info.systemname