Paul Posted December 9, 2008 Share Posted December 9, 2008 Hello!! I have a small problem writing this. #Include <Excel.au3> $sFilePath1 = "C:\Users\admin\Desktop\NovOrders.xls" $oExcel = _ExcelBookOpen($sFilePath1) $i = 1 (I want to start with the first A1) Do $sCellValue = _ExcelReadCell($oExcel, 1, $i) (Here I execute a window) Send("{TAB 1}") Send($sCellValue) Send("{TAB 2}") Send("{ENTER}") Until $sCellValue = 0 (Repeat from Do Until the CellValue=0) I'm doing something wrong. Any clues?? Thanks! Link to comment Share on other sites More sharing options...
Valuater Posted December 9, 2008 Share Posted December 9, 2008 This is one example of the "loop" you wanted ****** NOT TESTED #include <Excel.au3> $sFilePath1 = "C:\Users\admin\Desktop\NovOrders.xls" $oExcel = _ExcelBookOpen($sFilePath1) Local $i = 0 ;(I want to start with the first A1) Do $i += 1 $sCellValue = _ExcelReadCell($oExcel, 1, $i) If @error Then ExitLoop ;(Here I execute a window) Run("notepad.exe") WinWaitActive("") Send("{TAB 1}") Send($sCellValue) Send("{TAB 2}") Send("{ENTER}") Until $sCellValue = 0 ;(Repeat from Do Until the CellValue=0) 8) Link to comment Share on other sites More sharing options...
Paul Posted December 9, 2008 Author Share Posted December 9, 2008 Thanks!! I tried it out, I seem to be missing something still since it will just stop after the first ReadCell. It won't keep doing it with A2. Any ideas?? thanks a lot! This is one example of the "loop" you wanted ****** NOT TESTED #include <Excel.au3> $sFilePath1 = "C:\Users\admin\Desktop\NovOrders.xls" $oExcel = _ExcelBookOpen($sFilePath1) Local $i = 0 ;(I want to start with the first A1) Do $i += 1 $sCellValue = _ExcelReadCell($oExcel, 1, $i) If @error Then ExitLoop ;(Here I execute a window) Run("notepad.exe") WinWaitActive("") Send("{TAB 1}") Send($sCellValue) Send("{TAB 2}") Send("{ENTER}") Until $sCellValue = 0 ;(Repeat from Do Until the CellValue=0) 8) Link to comment Share on other sites More sharing options...
Andreik Posted December 9, 2008 Share Posted December 9, 2008 (edited) Just tested this example for cells A1-A5 and works good: #include <Excel.au3> $oExcel = _ExcelBookOpen($sFilePath1) $sCellsValue = _ExcelReadArray($oExcel,1,1,5,1,1) _ExcelBookClose($oExcel,0,0) Run("notepad.exe") WinWaitActive("") For $INDEX = 1 To $sCellsValue[0] Send("{TAB 1}") Send($sCellsValue[$INDEX]) Send("{TAB 2}") Send("{ENTER}") Next MsgBox(0,"","FINISH") And you don't need any loop. Or this example, writing results directly in the file. #include <Excel.au3> #include <File.au3> $sFilePath1 = @ScriptDir & "\Test.xls" $oExcel = _ExcelBookOpen($sFilePath1,0) $sCellsValue = _ExcelReadArray($oExcel,1,1,5,1,1) _ExcelBookClose($oExcel,0,0) _FileWriteFromArray(@ScriptDir & "\Result.txt",$sCellsValue,1) Edited December 9, 2008 by Andreik When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Paul Posted December 9, 2008 Author Share Posted December 9, 2008 Thanks! But I have to do it one by one. Read A1 Put in a form in firefox Read A2 Put in a new form in firefox so and on until A1=0 Just tested this example for cells A1-A5 and works good: #include <Excel.au3> $oExcel = _ExcelBookOpen($sFilePath1) $sCellsValue = _ExcelReadArray($oExcel,1,1,5,1,1) _ExcelBookClose($oExcel,0,0) Run("notepad.exe") WinWaitActive("") For $INDEX = 1 To $sCellsValue[0] Send("{TAB 1}") Send($sCellsValue[$INDEX]) Send("{TAB 2}") Send("{ENTER}") Next MsgBox(0,"","FINISH") And you don't need any loop. Link to comment Share on other sites More sharing options...
Andreik Posted December 9, 2008 Share Posted December 9, 2008 (edited) Thanks! But I have to do it one by one. Read A1 Put in a form in firefox Read A2 Put in a new form in firefox so and on until A1=0But you can have it one by one, only the results is in an array; It is exactly as you read the xls file. For $INDEX = 1 To $sCellsValue[0] MsgBox(0,"A" & $INDEX,$sCellsValue[$INDEX]) Next If is more easy for you: #include <Excel.au3> $CellNums = InputBox("Number of cells","Type here the number of cells",5) $oExcel = _ExcelBookOpen($sFilePath1,0) For $INDEX = 1 To $CellNums $sCellValue = _ExcelReadCell($oExcel,$INDEX) MsgBox(0,"Cell: A" & $INDEX,$sCellValue) #cs (Here I execute a window) Send("{TAB 1}") Send($sCellValue) Send("{TAB 2}") Send("{ENTER}") #ce Next _ExcelBookClose($oExcel,0,0) Edited December 9, 2008 by Andreik When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Paul Posted December 9, 2008 Author Share Posted December 9, 2008 Thanks!! Works perfectly! I owe you. But you can have it one by one, only the results is in an array; It is exactly as you read the xls file. For $INDEX = 1 To $sCellsValue[0] MsgBox(0,"A" & $INDEX,$sCellsValue[$INDEX]) Next If is more easy for you: #include <Excel.au3> $CellNums = InputBox("Number of cells","Type here the number of cells",5) $oExcel = _ExcelBookOpen($sFilePath1,0) For $INDEX = 1 To $CellNums $sCellValue = _ExcelReadCell($oExcel,$INDEX) MsgBox(0,"Cell: A" & $INDEX,$sCellValue) #cs (Here I execute a window) Send("{TAB 1}") Send($sCellValue) Send("{TAB 2}") Send("{ENTER}") #ce Next _ExcelBookClose($oExcel,0,0) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now