Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

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

End If

If Not IsObject(Connection) Then

Set Connection = Application1.Children(0)

End If

If Not IsObject(session) Then

Set session = Connection.Children(0)

End If

If IsObject(WScript) Then

WScript.ConnectObject session, "on"

WScript.ConnectObject Application1, "on"

End If

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.


Anup Nair

Former Member

Hi Anup,

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 = "SP1" then exit for



0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question