title: FS10N, how to choose layout by name with script in excel VBA?
body: <p>I'm writing a code in Excel VBA to automatically download data from SAP FS10N report.
  The only problem I have right now is that I can't find any solution to select the layout I wan't to use by the name of the layout. This is the code line I found to be the solution but it doesn't work for me:</p>
  <pre><code>Session.findById(&quot;wnd[1]/usr/ssubD0500_SUBSCREEN:SAPLSLVC_DIALOG:0501/cntlG51_CONTAINER/shellcont/shell&quot;)
  </code></pre>
  <h2>Any idea how to move on?</h2>
  <p>Edit:
  This is the part of my code where I can't access the pop up window which shows the available layouts. And so I can't select any layout by it's name, only the way the script recorder saved the way I did it manually:</p>
  <pre><code>session.findById(&quot;wnd[0]/tbar[1]/btn[33]&quot;).press
  session.findById(&quot;wnd[1]&quot;).sendVKey 81
  session.findById(&quot;wnd[1]&quot;).sendVKey 81
  session.findById(&quot;wnd[1]&quot;).sendVKey 81
  session.findById(&quot;wnd[1]&quot;).sendVKey 81
  session.findById(&quot;wnd[1]/usr/lbl[1,12]&quot;).setFocus
  session.findById(&quot;wnd[1]/usr/lbl[1,12]&quot;).caretPosition = 3
  session.findById(&quot;wnd[1]&quot;).sendVKey 2
  </code></pre>
  <h2>The repeating lines 2-5 show where I was scrolling up the list.</h2>
  <p>Edit2:
  This is what my script looks like when recorded:</p>
  <pre><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;fs10n&quot;
  session.findById(&quot;wnd[0]&quot;).sendVKey 0
  session.findById(&quot;wnd[0]/usr/ctxtSO_SAKNR-LOW&quot;).text = &quot;884050&quot;
  session.findById(&quot;wnd[0]/usr/txtGP_GJAHR&quot;).text = &quot;2020&quot;
  session.findById(&quot;wnd[0]/usr/txtGP_GJAHR&quot;).setFocus
  session.findById(&quot;wnd[0]/usr/txtGP_GJAHR&quot;).caretPosition = 4
  session.findById(&quot;wnd[0]&quot;).sendVKey 0
  session.findById(&quot;wnd[0]/tbar[1]/btn[8]&quot;).press
  session.findById(&quot;wnd[0]/usr/cntlFDBL_BALANCE_CONTAINER/shellcont/shell&quot;).setCurrentCell 1,&quot;BALANCE&quot;
  session.findById(&quot;wnd[0]/usr/cntlFDBL_BALANCE_CONTAINER/shellcont/shell&quot;).selectedRows = &quot;1&quot;
  session.findById(&quot;wnd[0]/usr/cntlFDBL_BALANCE_CONTAINER/shellcont/shell&quot;).doubleClickCurrentCell
  session.findById(&quot;wnd[0]/tbar[1]/btn[33]&quot;).press
  
  'My problem starts here
  
  session.findById(&quot;wnd[1]&quot;).sendVKey 81
  session.findById(&quot;wnd[1]&quot;).sendVKey 81
  session.findById(&quot;wnd[1]&quot;).sendVKey 81
  session.findById(&quot;wnd[1]&quot;).sendVKey 81
  session.findById(&quot;wnd[1]/usr/lbl[1,12]&quot;).setFocus
  session.findById(&quot;wnd[1]/usr/lbl[1,12]&quot;).caretPosition = 2
  session.findById(&quot;wnd[1]&quot;).sendVKey 2
  </code></pre>
  <p>I wan't somehow replace the last seven lines. I wan't to somehow select a layout by it's name in the dialog box. I hope this is more clear now.</p>
  <p>Edit3:
  The line above my comment:
  session.findById(&quot;wnd[0]/tbar<a href="https://i.stack.imgur.com/hgWJH.png" rel="nofollow noreferrer">1</a>/btn[33]&quot;).press
  Opens the layout select dialog box:
  <img src="https://i.stack.imgur.com/hgWJH.png" alt="FS10N G/L Account Line Item Display" /></p>
  <p>After clicking the button, this dialog box opens:
  <img src="https://i.stack.imgur.com/Nx4VD.png" alt="ALV layout selection screen as ABAP List rendering" /></p>
  <p>The last 7 lines of the code are my manual steps scrolling up 4 times, and selecting the wanted layout. Recorder doesn't help me identify the dialog box.</p>