title: How to close SAP pop-up windows with VBA?
body: <p>I would have liked to have automated several extraction except that when I run the macro I have pop-up windows that annoy me terribly I can make them disappear by pressing enter.</p>
  <pre><code>  Public Sub RunGUIScript()
  
   Dim W_Ret As Boolean
   Dim Société As String
   Sheets(&quot;Extraction&quot;).Select
   Société = Range(&quot;b9&quot;)
  
  
     Application.SendKeys &quot;{Enter}&quot; 
  
   ' Connect to SAP
    W_Ret = Attach_Session
    If Not W_Ret Then
    Exit Sub
     End If
  
  
      On Error GoTo myerr
  
  
  
    objSess.findById(&quot;wnd[0]&quot;).maximize
    objSess.findById(&quot;wnd[0]/tbar[0]/okcd&quot;).Text = &quot;S_ALR_87012039&quot;
    objSess.findById(&quot;wnd[0]/tbar[0]/btn[0]&quot;).press
    objSess.findById(&quot;wnd[0]/usr/radSUMMB&quot;).Select
    objSess.findById(&quot;wnd[0]/usr/chkP_GRID&quot;).Selected = True
    [...]
  
    Exit Sub
  
    myerr:
    MsgBox &quot;Error occured while retrieving data&quot;, vbCritical + vbOKOnly
  
  
    End Sub
  </code></pre>
  <p>The &quot;Application.SendKeys &quot;{Enter}&quot; feature does not make my SAP windows disappear so it is not the solution that works</p>
  <p><img src="https://i.stack.imgur.com/Py1ZO.png" alt="Windows popup A script attempts connecting to SAP GUI" /></p>
  <p><img src="https://i.stack.imgur.com/hfIzu.png" alt="SAP popup No data was selected" /></p>