title: Error The control could not be found by id
body: <p>I just started learning SAP GUI Scripting and cannot figure out why my macro is not recorded properly.</p>
  <ol>
  <li><p>I tried to record all the steps for a transaction at once. But every time I do it, a script contains only the part up until the line where a transaction is run. The rest of the steps are not recorded.</p>
  </li>
  <li><p>I decided to record two parts separately and combine them manually. But it still does not work.</p>
  </li>
  </ol>
  <p><strong>The macro only runs &quot;/oCS15&quot; transaction, it then stops and returns the error message:</strong></p>
  <blockquote>
  <p>the control could not be found by id. Line 20, Char 1</p>
  </blockquote>
  <p>Can anyone advise how to fix a problem? I really hope to move on with this part of the project and assume it is just a minor issue. Please help!</p>
  <p>I have the following script:</p>
  <pre class="lang-vb prettyprint-override"><code>If Not IsObject(application) Then
     Set SapGuiAuto  = GetObject(&quot;SAPGUI&quot;)
     Set application = SapGuiAuto.GetScriptingEngine
  End If
  If Not IsObject(connection) Then
     Set connection = application.Children(0)
  End If
  If Not IsObject(session) Then
     Set session    = connection.Children(0)
  End If
  If IsObject(WScript) Then
     WScript.ConnectObject session,     &quot;on&quot;
     WScript.ConnectObject application, &quot;on&quot;
  End If
  session.findById(&quot;wnd[0]&quot;).maximize
  session.findById(&quot;wnd[0]/tbar[0]/okcd&quot;).text = &quot;/oCS15&quot;
  session.findById(&quot;wnd[0]&quot;).sendVKey 0
  session.findById(&quot;wnd[0]/usr/chkRC29L-DIRKT&quot;).selected = true
  session.findById(&quot;wnd[0]/usr/ctxtRC29L-MATNR&quot;).text = &quot;EDG001001008&quot;
  session.findById(&quot;wnd[0]/usr/chkRC29L-DIRKT&quot;).setFocus
  session.findById(&quot;wnd[0]&quot;).sendVKey 5
  session.findById(&quot;wnd[0]/usr/ctxtRC29L-WERKS&quot;).text = &quot;0600&quot;
  session.findById(&quot;wnd[0]/usr/ctxtRC29L-WERKS&quot;).setFocus
  session.findById(&quot;wnd[0]/usr/ctxtRC29L-WERKS&quot;).caretPosition = 4
  session.findById(&quot;wnd[0]&quot;).sendVKey 8
  session.findById(&quot;wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell&quot;).currentCellColumn = &quot;DOBJT&quot;
  session.findById(&quot;wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell&quot;).selectedRows = &quot;0&quot;
  session.findById(&quot;wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell&quot;).doubleClickCurrentCell
  session.findById(&quot;wnd[0]/usr/tabsTS_ITEM/tabpPHPT/ssubSUBPAGE:SAPLCSDI:0830/btnP_BEZIEHUNG&quot;).press
  session.findById(&quot;wnd[0]/usr/cntlSOURCE/shellcont/shell&quot;).setSelectionIndexes 0,28
  </code></pre>