I wanna pimp up my code for not having many restrictions. I start my Macro like this. There I define the Application, Connection and session. The last comment ist just a placeholder for the SAP gui Skript from recorder.
Public SapGuiAuto
Public objGui As GuiApplication
Public objConn As GuiConnection
Public session As GuiSession
'--- Funktion für SAP-Anbindung ---
Sub SAPCustomerReport()
'--- Verbindungsaufbau zur SAP Sitzung ---
Set SapGuiAuto = GetObject("SAPGUI")
Set objGui = SapGuiAuto.GetScriptingEngine
Set objConn = objGui.Children(0)
Set session = objConn.Children(0)
'-- SKRIPT AUS DEM SAP RECORDER
End Sub
Now i want to make a loop that goes through all open windows until it find first the "1_RPR". After it finds this it should do the transaction. If this is finished i want to loop again to search for a open window that belongs to "5_SPH" and do there the same process. For the distinction I made this code but I don't know how to make the loop over the open windows.
Dim Test1 As String
If objConn.Description = "1_RPR" Then
Test1 = "RPR"
'Skript für RPR Transaktion <---
ElseIf objConn.Description = "5_SPH" Then
Test1 = "SPH/APO"
'Skript für SPH/APO Transaktion <---
Else
GoTo KeineSitzung
End If
A pre-condition is that someone is logged on to minimum 1 of the servers. If It doesn't fit I will make a MsgBox("No Session of RPR or SPH available.").