kctvt Posted February 9, 2011 Share Posted February 9, 2011 (edited) Should use For Next or Do Until or Something. Yah, this's my question today. I got a problem and ... I think I need help. This's my code now : expandcollapse popup#include <IE.au3> #include <File.au3> #include <Array.au3> #include <Date.au3> #Include <Excel.au3> #include <Word.au3> $part = @ScriptDir&"\Care.xls" $oExcel = _ExcelBookOpen($part) Sleep(1000) Run ("Notepad.exe") WinWaitActive("Untitled - Notepad") ControlSend("[CLASS:Notepad]", "", "Edit1", "Hello, this is the first line) Sleep(500) Send("{ENTER}") Sleep(500) Do $i = 6 $Name = _ExcelReadCell($oExcel,$i,1) $Age = _ExcelReadCell($oExcel,$i,1) $Sex = _ExcelReadCell($oExcel,$i,3) $Info = ("===============" & @CR & $Name & $Age & $Sex & "==================" & @CR") IF _ExcelReadCell($oExcel,$i,4) = "" then ControlSend("[CLASS:Notepad]", "", "Edit1", $Info) Sleep(500) EndIf $i = $i + 1 Until _ExcelReadCell($oExcel,$i,1) = "" ---> Problem is : $i dont change from 6 to 7, 7 to 8, 8 to 9, 9 to 10. $i still 6, not change. And this's my Excel file : 1 |2 |3 |4 ---------------------------------- Peter |25 |Male | Tom |26 |Male | Mary |30 |Female |Save Daisy |19 |Female | I want the code read Excel file, then If NUMBER 4 dont write "Save" , the code'll take value from that Row and paste to Notepad. They'll take the value of all Row until NUMBER 1 = "" --> I want to do that. But @_@ I dont know how. Edited February 9, 2011 by kctvt Link to comment Share on other sites More sharing options...
hannes08 Posted February 9, 2011 Share Posted February 9, 2011 Hi kctvt, what you coded here is an infinite loop, as you always set $i = 6 on the beginning of every loop. Consider changing it to "$i = 1" before beginning the loop and at the end of the loop to "$i += 1" to iterate. Regards, Hannes Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
kctvt Posted February 9, 2011 Author Share Posted February 9, 2011 (edited) ok. THanks Hannes. This code works expandcollapse popup#include <IE.au3> #include <File.au3> #include <Array.au3> #include <Date.au3> #Include <Excel.au3> #include <Word.au3> $part = @ScriptDir&"\Care.xls" $oExcel = _ExcelBookOpen($part) Sleep(1000) Run ("Notepad.exe") WinWaitActive("Untitled - Notepad") ControlSend("[CLASS:Notepad]", "", "Edit1", "Hello, this is the first line) Sleep(500) Send("{ENTER}") Sleep(500) $i = 6 Do $Name = _ExcelReadCell($oExcel,$i,1) $Age = _ExcelReadCell($oExcel,$i,1) $Sex = _ExcelReadCell($oExcel,$i,3) $Info = ("===============" & @CR & $Name & $Age & $Sex & "==================" & @CR") IF _ExcelReadCell($oExcel,$i,4) = "" then ControlSend("[CLASS:Notepad]", "", "Edit1", $Info) Sleep(500) EndIf $i += 1 ;;;;;;; NOT $i = $i + 1 Until _ExcelReadCell($oExcel,$i,1) = "" Edited February 9, 2011 by kctvt Link to comment Share on other sites More sharing options...
hannes08 Posted February 9, 2011 Share Posted February 9, 2011 Hey kctvt, just a short sidenote: $i += 1 is the same as $i = $i + 1 Regards, Hannes Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] 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