title: How to take input from excel and use that value to run a macro in as400
body: <p>Today i am working on as400 macro, and i have a requirement to run the same macro for 3000+ records one by one. The excel sheet is containing those 3000+ lines in A column as a number format. Each time I need to run the macro and before that I need to change the AS400 macro code with the value from A column of the excel.</p>
  
  <p>Below is the code of the AS400 Macro.</p>
  
  <pre><code>[PCOMM SCRIPT HEADER]
  LANGUAGE=VBSCRIPT
  DESCRIPTION=
  [PCOMM SCRIPT SOURCE]
  OPTION EXPLICIT
  autECLSession.SetConnectionByName(ThisSessionName)
  
  REM This line calls the macro subroutine
  subSub1_
  
  sub subSub1_()
     autECLSession.autECLOIA.WaitForAppAvailable
  
     autECLSession.autECLOIA.WaitForInputReady
     autECLSession.autECLPS.SendKeys "dc74945"
     autECLSession.autECLOIA.WaitForInputReady
     autECLSession.autECLPS.SendKeys "[enter]"
  
     autECLSession.autECLPS.WaitForAttrib 5,28,"00","3c",3,10000
  
     autECLSession.autECLPS.WaitForCursor 5,29,10000
  
     autECLSession.autECLOIA.WaitForAppAvailable
  
     autECLSession.autECLOIA.WaitForInputReady
     autECLSession.autECLPS.SendKeys "[tab]"
     autECLSession.autECLOIA.WaitForInputReady
     autECLSession.autECLPS.SendKeys "7"
     autECLSession.autECLOIA.WaitForInputReady
     autECLSession.autECLPS.SendKeys "[enter]"
  
     autECLSession.autECLPS.WaitForAttrib 5,24,"00","3c",3,10000
  
     autECLSession.autECLPS.WaitForCursor 5,25,10000
  
     autECLSession.autECLOIA.WaitForAppAvailable
  
     autECLSession.autECLOIA.WaitForInputReady
     autECLSession.autECLPS.SendKeys "n"
     autECLSession.autECLOIA.WaitForInputReady
     autECLSession.autECLPS.SendKeys "[tab]"
     autECLSession.autECLOIA.WaitForInputReady
     autECLSession.autECLPS.SendKeys "[tab]"
     autECLSession.autECLOIA.WaitForInputReady
     autECLSession.autECLPS.SendKeys "[tab]"
     autECLSession.autECLOIA.WaitForInputReady
     autECLSession.autECLPS.SendKeys "[tab]"
     autECLSession.autECLOIA.WaitForInputReady
     autECLSession.autECLPS.SendKeys "[tab]"
     autECLSession.autECLOIA.WaitForInputReady
     autECLSession.autECLPS.SendKeys "nnn"
     autECLSession.autECLOIA.WaitForInputReady
     autECLSession.autECLPS.SendKeys "[tab]"
     autECLSession.autECLOIA.WaitForInputReady
     autECLSession.autECLPS.SendKeys "n"
     autECLSession.autECLOIA.WaitForInputReady
     autECLSession.autECLPS.SendKeys "[enter]"
  end sub
  </code></pre>
  
  <p>Now each time I need to change the below line by taking input from excel.</p>
  
  <pre><code>autECLSession.autECLPS.SendKeys "dc74945"
  </code></pre>
  
  <p>Excel contains data in below format:</p>
  
  <pre><code>ID  Name
  AC71182 Andrew Cain
  AC74398 Adam Cadman
  AD39903 Alisha Davies (CARDIFF)
  AC74952 Abby Clarke
  AD54561 Alison Duffield
  AD59529 Ann Rose Davies
  AD60488 Alex Delmonte C'Diff COMBO
  </code></pre>
  
  <p>What I am looking for is an AS400 macro to read one by one cell from Column A in excel (containing ID) and then run the above macro for that ID by changing the value in the above mentioned line.</p>
  
  <p>I searched a lot, but never find an easy way to do so by using AS400 Macro.
  I got VBA macro to do such things, but I need AS400 Macro. So requesting your help if you can.</p>
  
  <p>Thanks, 
  Maitreya</p>