aic2011 Posted December 5, 2011 Share Posted December 5, 2011 We wrote a script to copy and paste value from Excel table. Is it possible to end that command if the value copied on the excel table is null or empty? So We are running a while loop to copy and paste from cell 1, cell 2, cell 3 etc and if cell 4 is empty or has no value, end the while loop. So it needs to read the copied value and see if it is null or empty and decide based on that. Any ideas on how we should do that? Link to comment Share on other sites More sharing options...
Country73 Posted December 5, 2011 Share Posted December 5, 2011 Depends on how you wrote your script. Taking a stab in the dark, within the Loop: If $Value = "" Then Exitloop Get a better response if you post the actual code in question. If you try to fail and succeed which have you done?AutoIt Forum Search Link to comment Share on other sites More sharing options...
aic2011 Posted December 5, 2011 Author Share Posted December 5, 2011 (edited) Here you go. Thanks for helping. While 1 If ClipGet() <> "" Then Send("{ALT DOWN}{TAB}{ALT UP}") _WinWaitActivate("Microsoft Excel - newOrder","") Send("{DOWN}") Send("^c") Send("{ALT DOWN}{TAB}{ALT UP}") _WinWaitActivate("R7CPQ6 @ (365)","") Send("^v") Send("{ENTER}") Send("{ENTER}") EndIf If ClipGet() = "" Then ExitLoop Send("{ALT DOWN}{TAB}{ALT UP}") _WinWaitActivate("Microsoft Excel - newOrder","") Send("{DOWN}") Send("^c") Send("{ALT DOWN}{TAB}{ALT UP}") _WinWaitActivate("- R7CPQ6 @ (365)","") Send("^v") Send("{ENTER}") EndIf WEnd - the clipget() = "" does not exit the loop. Edited December 5, 2011 by aic2011 Link to comment Share on other sites More sharing options...
Country73 Posted December 5, 2011 Share Posted December 5, 2011 (edited) You may want to look into using the "ExcelCOM_UDF.au3" or at least the "Excel.au3"; would make things a lot easier.#include <ExcelCOM_UDF.au3> Local $eFile = "" ;Excel file to open Local $oExcel = _ExcelBookOpen($eFile,0,True) ;Excel File, Not Visible, Read Only If Not @error = 1 Or Not @error = 2 Then ;1=can't create Excel Object, 2=File not found _ExcelSheetActivate($oExcel,1) ;Excel Variable for file open, specified sheet Local $eValue, $eRow = 1 Do $eValue = $oExcel.Cells($eRow,1).Value ;Sets $eValue to specified row, column 1 value If $eValue = "" Then ExitLoop ;Cell is empty ;Put coding in for what you want to do with the $eValue here $eRow += 1 ;go to next row Until $oExcel.Cells($eRow,1).Value = "" ;Row is empty Else ; Message for Excel not found/opened EndIf _ExcelBookClose($oExcel) ;Close your Excel fileThat should be a fairly good example to get you startedEdit: Here's a link to the AU3 files mentioned Edited December 5, 2011 by Country73 If you try to fail and succeed which have you done?AutoIt Forum Search 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