title: distinction between SAP servers VIA EXCEL VBA
body: <p>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.</p>
  <pre><code>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(&quot;SAPGUI&quot;)
      Set objGui = SapGuiAuto.GetScriptingEngine
      Set objConn = objGui.Children(0)
      Set session = objConn.Children(0)
   
      '-- SKRIPT AUS DEM SAP RECORDER
  
  End Sub
  </code></pre>
  <p><strong>Now i want to make a loop that goes through all open windows until it find first the &quot;1_RPR&quot;. 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 &quot;5_SPH&quot; 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.</strong></p>
  <pre><code>Dim Test1 As String
       If objConn.Description = &quot;1_RPR&quot; Then
          Test1 = &quot;RPR&quot;
                                                          'Skript für RPR Transaktion &lt;---
       ElseIf objConn.Description = &quot;5_SPH&quot; Then
          Test1 = &quot;SPH/APO&quot;
                                                          'Skript für SPH/APO Transaktion &lt;---
       Else
          GoTo KeineSitzung
       End If
  </code></pre>
  <p>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(&quot;No Session of RPR or SPH available.&quot;).</p>